Forum Discussion
Transform a text dimension into a measure?
- 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!
😁😁
- 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.
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!
😁😁
Hello freginier
Yes it give me the same result (and by the way the last UNICHAR(10) seems even not to be necessary 😀 )
To be honest, I would have thought to be challenged on the CONCATENATEX and not the CALCULATETABLE(ADDCOLUMNS.
So, to transform a text dimension into a measure CONCATENATEX is always the correct instruction?