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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
ChrisFromOhio
Helper I
Helper I

SWITCH Function in Matrix not working

Hello all - I am attempting to build out a matrix visualization with a tooltip chart that will change based on the metric the user is hovering over. In my dataset (called Sales), I have a variety of measures (Sales $, Sales U, Cost $). I want to add a fourth measure, which is Margin % (Cost $/Sales $). I am able to do this if I create the measures in the Sales table using the calculate function. However, I cannot get a tooltip chart to change the visualization based on the value selected.

 

Therefore, my workaround was to create a separate table called Metrics, with the four metrics listed above. I then created a SWITCH measure, depending on which metric was selected in the table, would present that calculation. I had to create a relationship between the metric names in the Metric table and the measure names in the Sales table. 

 

This works great, except for the calculated measure of Margin %. I'm assuming this is because there is no Margin % measure name in the Sales table. Are there any solutions out there that would solve this problem?

 

Sample PBI file here.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @ChrisFromOhio ,

 

Not quite sure what you mean, you might consider displaying the corresponding MEASURES based on the slicer selection

Here are the steps you can follow:

1. Use Enter data to create a table with no join relationships that contains the names of the four measure

vyangliumsft_0-1739332908070.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Slicer_Table'[Slicer])
RETURN
SWITCH(
    TRUE(),
_select = "Sales $",[Sales $],
_select = "Sales U",[Sales U],
_select = "Cost $",[Cost $],
_select = "Margin %",[Margin %])

3. Result:

vyangliumsft_1-1739332908071.png

If the results above don't match your expected results, you can express your expected results in the form of a picture and we can help you better!

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @ChrisFromOhio ,

 

Not quite sure what you mean, you might consider displaying the corresponding MEASURES based on the slicer selection

Here are the steps you can follow:

1. Use Enter data to create a table with no join relationships that contains the names of the four measure

vyangliumsft_0-1739332908070.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Slicer_Table'[Slicer])
RETURN
SWITCH(
    TRUE(),
_select = "Sales $",[Sales $],
_select = "Sales U",[Sales U],
_select = "Cost $",[Cost $],
_select = "Margin %",[Margin %])

3. Result:

vyangliumsft_1-1739332908071.png

If the results above don't match your expected results, you can express your expected results in the form of a picture and we can help you better!

 

Best Regards,

Liu Yang

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

Hi @Anonymous

Thank you for your reply. Solution was to break the relationship. Thanks!

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.