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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Smile
Frequent Visitor

Setting different data types for measures used in SWITCH function

Hi,

 

I have two values in my SWITCH function as below:

SWITCH (

        SELECTEDVALUE('ColumnA')

        ,1, CURRENCY('Sales') -- and added $ in front of the displayed currency by using the $ sign button under Format in the top ribbon

        ,2, FORMAT('UnitCount', "#,##0")

)

 

With the above, I could display 'Sales' in the format, $1,234 whereas 'UnitCount' in the format, 1,234. -> (1)

However, I quickly realised that with this, I am not able to sort 'UnitCount' by values as is in the data type, Text.

When I tried switching 'UnitCount' to VALUE('UnitCount'), it added $ sign in front of the number, which is not the desired outcome.

 

Does anyone have recommendation as to how I can still show the values in the necessary format (1) and allow users to sort by their numberical values for both 'Sales' and 'UnitCount'?

 

Thank you!

1 ACCEPTED SOLUTION
djurecic
Super User
Super User

Hi @Smile ,

 There is not a way to do this with a SWITCH statement. Microsoft recommends trying calculation groups.

You can vote for the idea here:

https://ideas.powerbi.com/ideas/idea/?ideaid=09c2a6d2-d215-4d68-b500-21167d177461

 

Calculation groups:

https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/

 

 

View solution in original post

2 REPLIES 2
Smile
Frequent Visitor

Thank you so much for your help here @djurecic !

djurecic
Super User
Super User

Hi @Smile ,

 There is not a way to do this with a SWITCH statement. Microsoft recommends trying calculation groups.

You can vote for the idea here:

https://ideas.powerbi.com/ideas/idea/?ideaid=09c2a6d2-d215-4d68-b500-21167d177461

 

Calculation groups:

https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.