Search code examples
powerbidax

How to conditionally display decimals in a measure in Power BI


Let's say I have a simple measure like this:

SimpleMeasure = MyTable[Column1]/MyTable[Column2]

Is it possible to have the number of displayed decimals dependent on the value? For example, if my measure calculates the number 500, then I don't want to see 500.00 but rather 500. However if my measure calculates 0.56, then I want to see the value displayed like that to two decimal places and not rounded to the number 1.

So a possible visualization table would look like this:

Store   SimpleMeasure
00      10
01      18
02      0.67
03      6

Thank you in advance!


Solution

  • IF(
    [SimpleMeasure] < 1, FORMAT([SimpleMeasure], "#,##0.##",
    FORMAT([SimpleMeasure], "#,##0")
    )