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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Unpivoted data, wrote a switch function to format percentages and currency, not pulling through?

I am putting together a P&L report where I want to display the line items in a matrix. It has a mix of percentage and currency values things like standard margin. I created a measure and wrote the following switch statement (snippet below) and I'm not getting any errors, but the values are not coming through

Formatted Value =
SWITCH(
    SELECTEDVALUE('Merchandising P&L'[Header]),
    "DC cost %", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "Freight cost %", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "G2N% (Gross Sales)", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "Operational Gross Margin% (COPA)", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "SM%", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "Total SM%", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Percent"),
    "COS", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Currency"),
    "Distribution Center Cost", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Currency"),
    "FIFO", FORMAT(SELECTEDVALUE('Merchandising P&L'[Value]),"Currency"))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

First of all, thanks @HotChilli  for the quick reply. 

You can try it.

Formatted Value2 = SUM('Merchandising P&L'[Value])
SWITCH(
    SELECTEDVALUE('Merchandising P&L'[Header]),
    "DC cost %", "00.00%",
    "Freight cost %", "00.00%",
    "G2N% (Gross Sales)", "00.00%",
    "Operational Gross Margin% (COPA)", "00.00%",
    "SM%", "00.00%",
    "Total SM%", "00.00%",
    "COS", "$0.00",
    "Distribution Center Cost", "$0.00",
    "FIFO", "$0.00")

vtangjiemsft_0-1719904806293.png

'

vtangjiemsft_1-1719904825900.png

 

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Hi @Anonymous ,

 

First of all, thanks @HotChilli  for the quick reply. 

You can try it.

Formatted Value2 = SUM('Merchandising P&L'[Value])
SWITCH(
    SELECTEDVALUE('Merchandising P&L'[Header]),
    "DC cost %", "00.00%",
    "Freight cost %", "00.00%",
    "G2N% (Gross Sales)", "00.00%",
    "Operational Gross Margin% (COPA)", "00.00%",
    "SM%", "00.00%",
    "Total SM%", "00.00%",
    "COS", "$0.00",
    "Distribution Center Cost", "$0.00",
    "FIFO", "$0.00")

vtangjiemsft_0-1719904806293.png

'

vtangjiemsft_1-1719904825900.png

 

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

HotChilli
Super User
Super User

Normally it's very hard to look at a piece of DAX and diagnose problems without a data sample or the context of the visual.

However, it looks like the generous use of FORMAT has scuppered your values, turning them into strings.

 

Anonymous
Not applicable

I've tried about a half dozen different things between conditional columns and I'm just not getting anywhere 😛 I saw this work on a less complex example posted elsewhere, but I'm not having any luck

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors