cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-Format Numbers in Billions, Millions, Thousands, etc.

Hi,

I came across the need to have charts auto-format numbers depending on their size. For example, if numbers are in billions, format in billions. Same thing for millions and thousands. Would like to prevent users from having to scroll to see all the columns, and this would help in that regard.

Thanks!

Josh

Status: New
Comments
Advocate IV

Great idea. I've written DAX to do this dynamically. 

df Total = 
VAR SafeLog =
    IFERROR ( ABS(INT ( LOG ( ABS ( [Total] ), 1000 ) )), 0 )
VAR dp = 1
RETURN
    ROUND ( DIVIDE ( [Total], 1000 ^ SafeLog ), dp )
        & SWITCH ( Safelog, 1, "K", 2, "M", 3, "bn", 4, "tn" )
 

 

See this Twitter thread: https://twitter.com/InsightsMachine/status/1313428654647472128

 

Something similar can also be used inside Calculation Groups to keep the numbers as numbers, as per this thread: https://twitter.com/InsightsMachine/status/1313603548995751937?s=20