This post is also available in: Deutsch
Automatic scaling of metrics or measures is possible in Power BI for just about any visual. However, there is currently no possibility to dynamically adjust tables or the matrix.
With this selection the values can be displayed in millions, for example.
Even if the values are restricted due to a slicer, filter or drill down, the manually set scaling is kept. Depending on the constellation, this leads to the strange situation that no more information can be obtained from the report because the values are too low for scaling.
While this is handled in a graphical visual and the scaling is adjusted, this option is unfortunately not available in a table or matrix.
Dynamic scaling with DAX
However, you can influence the formatting directly in a DAX measure so that it automatically adapts to the displayed value. The FORMATfunction will help us here. This function is similar to the formatting in Excel and only allows us to adjust the visualization, the values remain unchanged.
The following syntax would display the value as a normal number:
The documentation for custom formats shows us that a comma helps to “shrink” the displayed number in blocks of thousands. In a nutshell, each comma shows 3 digits less.
So the representation in thousands would be for our measure:
To get the representation in millions an additional comma is sufficient:
Which scaling should be displayed we have to define in the measure. Here we calculate whether the given number can be divided by 1,000, 1,000,000 or 1,000,000,000 and then return the value in the appropriate formatting.
This can be done by nested IF functions, but I personally prefer a SWITCH(TRUE() for clarity reasons.
When we now display this measure in our table, the scaling is automatically adjusted. No matter if we have the overall view:
And also when we filter on individual customers:
However, the approach still has 2 disadvantages:
- Since the FORMATfunction returns the value as text, the measure can unfortunately not be displayed in graphics.
- As already mentioned, since it is text, the decimal places can unfortunately not be adjusted dynamically.