Forum Discussion
powerbiexpert22
Impactful Individual
7 days agoData Labels and Y Axis - Dynamic Format String
i am using dynamic string for measures in my below shown bar chart, i am using below measure as example , i want to how data labels and Y axis values in thousands or millions with two decimal places ...
Shai_Karmani
Super User
7 days agoYou can handle this directly in the Dynamic Format String by using the trailing comma trick to scale, then adding the suffix as a literal. Both the data labels and Y axis labels pick up the dynamic format per value in current Power BI versions.
Try this as the format string expression on the measure:
VAR _abs = ABS(SELECTEDMEASURE())
RETURN
SWITCH(
TRUE(),
_abs >= 1E6, "#,##0.00,, M",
_abs >= 1E3, "#,##0.00, K",
"#,##0.00"
)
Each trailing comma in the format string divides the number by 1,000, so 6,200,000 renders as 6.20 M and 54,644 as 54.64 K. If you also need a billions tier, add another branch with "#,##0.00,,, B" above the millions check.
If this helped, please mark it as the accepted solution and give it a thumbs up.
Best regards,
Shai Karmani