Forum Discussion

s4muel's avatar
s4muel
Frequent Visitor
1 year ago
Solved

Transform a text dimension into a measure?

Hello, My business case: create a measure (green frame) that displays a dimension (blue frame) by replacing the value separator ( | ) by a line break.                       Here my...
  • freginier's avatar
    1 year ago

    Hey there!

     

    If I understand correctly, you are trying to replace the " | " separator in a DAX measure with a line break (UNICHAR(10)). 

     

    You can simplify your DAX measure by directly using CONCATENATEX on the VALUES function without the need for CALCULATETABLE or ADDCOLUMNS, like this:

    Measure =
    IF(
    ISINSCOPE('Attribute Names Schema'[Attribute name]),
    CONCATENATEX(
    VALUES('Attribute Names Schema'[Value range]),
    SUBSTITUTE([Value range], "|", UNICHAR(10)),
    UNICHAR(10)
    )
    )

     

    This should give you a correct result!

    Hope this helps! 

    😁😁

  • danextian's avatar
    1 year ago

    Hi s4muel 

     

    CONCATENATEX isn't necessary but here are two measures that uses it and another one that doesnt

    FormattedText = 
    IF (
        ISINSCOPE ( 'Table'[Attribute] ),
        CONCATENATEX (
            'Table',
            SUBSTITUTE ( 'Table'[Value range], "|", UNICHAR ( 10 ) ),
            UNICHAR ( 10 )
        )
    )
    
    FormattedText2 = 
    IF (
        ISINSCOPE ( 'Table'[Attribute] ),
        SUBSTITUTE ( SELECTEDVALUE ( 'Table'[Value range] ), "|", UNICHAR ( 10 ) )
    )
    

    Please see the attached pbix.