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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
sumpekung
Frequent Visitor

Switch Function not working in other visuals such as bar chart.

Hi,

 

I'm trying to see old forums from others but don't see the exact answer U need to know.

I created a switch measure and it's working good with Matrix and Table visuals but it doesn't work with other visual such as Bar and Column charts, it can't even drag the switched measure into the Y axis field.

 

Note : I use powerBI May-2025 at my company, don't sure powerBI at workplace has more limit than common user or not?

1 ACCEPTED SOLUTION
Zanqueta
Super User
Super User

Hi @sumpekung, If you would like, you may share your exact SWITCH measure and I can help you refine it so that it behaves consistently across all visuals.

 

Quick verification you can perform now: 

  • The SWITCH works in Matrix and Table visuals because they support multiple data types.

  • Bar and column charts accept only numeric measures on the Y‑axis.

  • If any branch of the SWITCH produces a non‑numeric value, the measure is excluded from the Y‑axis.

  • Standardising all returned values to numeric types resolves the issue.

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

 

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

View solution in original post

2 REPLIES 2
Zanqueta
Super User
Super User

Hi @sumpekung, If you would like, you may share your exact SWITCH measure and I can help you refine it so that it behaves consistently across all visuals.

 

Quick verification you can perform now: 

  • The SWITCH works in Matrix and Table visuals because they support multiple data types.

  • Bar and column charts accept only numeric measures on the Y‑axis.

  • If any branch of the SWITCH produces a non‑numeric value, the measure is excluded from the Y‑axis.

  • Standardising all returned values to numeric types resolves the issue.

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

 

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

Many thanks, my current measure I try to formatted it because I have to show with Percentage and Whole Number.

 

My measure:

Sales Display (Formatted) =
SWITCH(
SELECTEDVALUE(DisplayType[Type]),
"Percent", FORMAT([Sales %], "0.00%"),
FORMAT([Total Sales], "#,##0")
)

 

It can works on bar chart after I removed the Format function. Anyway, does it possible to format it to show in Whole Number and Percentage? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.