Print

Show data labels in k or M in the same column | Dynamic formatting in Power BI

If you want to be able to conditional format a number in Power BI as k for thousands and M for millions in the same column, the new Dynamic Formatting can do that for you.

Watch the tutorial on YouTube

Show numbers in Thousands or Millions in same column with the new Dynamic formatting in Power BI

The code

And here is the code for the formatting: (updated so it formats negative values also)

VAR salesMeasure = [Total Sales]
return
SWITCH(TRUE(),
salesMeasure-1000000000000 && salesMeasure< -1000000000, "#,,,.0B",
salesMeasure-1000000000 && salesMeasure< -1000000, "#,,.0M",
salesMeasure> -1000000 && salesMeasure< -1000,"#,.0K",
salesMeasure<1000,"0",
salesMeasure<1000000, "#,.0K", 
salesMeasure<1000000000, "#,,.0M",
salesMeasure>=1000000000, "#,,,.0B")

But if you prefer the file, download it here – Community Downloads -#079

More tips and tricks on formatting data labels:

More Dynamic formatting AWESOMENESS!! | Annotations with dynamic formatting
DAX Fridays #220: SELECTEDMEASURE function
Was this helpful?

Reader Interactions

Comments

  1. Thanks a lot, really helpful!!! I used the code but noticed a small error:
    4th line under SWITCH
    salesMeasure<100000,"0", (THIS SHOUL BE salesMeasure<1000,"0",)

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents