How to show new line in SSAS tabular model attribute

Palash Aich 21 Reputation points
2023-02-08T10:01:26.6866667+00:00

Hello there,

I have values in SQL column as "Project Name: MSP \n\n Project Description: Billable \n\n Project Status: In Progress."

I am using this field in SSAS tabular model as an attribute and need to show a new line instead of \n. How can I show the value in the new line as shown below? Do I need to replace \n with something else in SQL or in the cube we should write an expression, please?

Expectation:

Project Name: MSP

Project Description: Billable

Project Status: In Progress

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,344 questions
SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Muhammad Ahsan Khan 250 Reputation points
    2023-03-27T10:42:17.5533333+00:00

    To show new lines in an SSAS tabular model attribute, you can use the following steps:

    1. In your SQL query, replace the "\n" characters with the appropriate new line character for your environment. For example, in SQL Server, you can use the CHAR(13) and CHAR(10) characters to represent new lines:
    SELECT REPLACE(REPLACE([YourColumnName], '\n', CHAR(13)), CHAR(10), '') AS [NewColumnName]
    FROM [YourTableName]
    
    1. In your SSAS tabular model, add the [NewColumnName] as a new attribute.
    2. In the properties of the attribute, select the "Format" option and choose "Custom".
    3. In the "Custom Format String" field, enter the following expression to replace the CHAR(13) character with a line break:
    =[NewColumnName].Value.Replace(Chr(13), VbCrLf)
    

    This should display the attribute with new lines instead of the "\n" characters.

    hope it helped!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.