Forum Discussion
Formatting values separately in unpivot value column
- 3 years ago
Hi harshadrokade ,
If you are using the latest version of Power BI you can use the Dynamic Format, create a measure and on the format select Dynamic then add the following code:
SWITCH ( TRUE (), SELECTEDVALUE ( 'Table'[Attribute] ) IN { "Parameter2", "Parameter4", "Parameter6" }, "#.0%", "#" )https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-dynamic-format-strings
Thanks MFelix This was very very helpful & I will use the same. Just one query- I have huge around 100 parameters which will be in % format. Will DAX format formula accept so many field names into the same?
But this was really good. Made my day 🙂 Thanks again
- MFelix3 years agoSuper User
Hi harshadrokade,
Power BI will accept, however being so many cases the best option is to create a new column on your model that defines in text the values for each format and then use that column on format in this case I have created a step on power query befor making the type format:
Has you can see if I have percentages then I do the percentage format.
Then I change the format dax to:
IF( HASONEVALUE('Table'[Attribute]), SELECTEDVALUE('Table'[Formatting String]))Result below:
No need to write any of your formula, in the future if you want to update the syntax you just need to change it in Power Query for example:
No I have two decimals without the need to change all the formula.
PBIX attach.