Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
FilipaPereira
Frequent Visitor

Dynamic formatting

How to apply dynamic formatting to the total.
I've applied dynamic formatting to distinguish between different currencies, € and $, but the total always appears in €, even if I only select data in $. How do I apply dynamic formatting to the total?
Here's what I've done

FilipaPereira_0-1752833907498.png

this is the formula I used

SWITCH(SELECTEDVALUE('Comisões'[Moeda]),
  "USD", "#,### $ "," #,###,## €")
 
1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @FilipaPereira  - you can create a measure as like below:

Currency Used =
IF (
HASONEVALUE('Comisões'[Moeda]),
SELECTEDVALUE('Comisões'[Moeda]),
IF (
COUNTROWS(VALUES('Comisões'[Moeda])) = 1,
VALUES('Comisões'[Moeda]),
"Mixed"
)
)

 

another measure is for formatting the total detection follow: replace the table name as per your model

Formatted Total Commissions =
VAR _value = [TotalCommissions]
VAR _currency = [Currency Used]

RETURN
SWITCH(
_currency,
"USD", FORMAT(_value, "#,##0.00 $"),
"EUR", FORMAT(_value, "#,##0.00 €"),
"Mixed", FORMAT(_value, "#,##0.00") & " (Mixed)",
FORMAT(_value, "#,##0.00") // fallback
)

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @FilipaPereira 

 

At the total level, your formula using SELECTEDVALUE returns blank because there is likely more than one value in 'Comisões'[Moeda]. Since this does not satisfy the first condition in your SWITCH statement, the measure falls back to the alternative result. This usually happens when there is no direct relationship between the slicer column and the column you are referencing in the dynamic format string expression, so the context does not filter down as expected.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
rajendraongole1
Super User
Super User

Hi @FilipaPereira  - you can create a measure as like below:

Currency Used =
IF (
HASONEVALUE('Comisões'[Moeda]),
SELECTEDVALUE('Comisões'[Moeda]),
IF (
COUNTROWS(VALUES('Comisões'[Moeda])) = 1,
VALUES('Comisões'[Moeda]),
"Mixed"
)
)

 

another measure is for formatting the total detection follow: replace the table name as per your model

Formatted Total Commissions =
VAR _value = [TotalCommissions]
VAR _currency = [Currency Used]

RETURN
SWITCH(
_currency,
"USD", FORMAT(_value, "#,##0.00 $"),
"EUR", FORMAT(_value, "#,##0.00 €"),
"Mixed", FORMAT(_value, "#,##0.00") & " (Mixed)",
FORMAT(_value, "#,##0.00") // fallback
)

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors