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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mphillenga
Helper I
Helper I

Hide or show different measures in a chart

Hello,

 

I have a chart with three lines showing: rural, urban and total market shares. My goal is that with a slicer you can select which of the lines to show. If none are selected (or "all"), all three lines should be shown.

 

The market share is measure calculated by calcuating and dividing other measures. In the data the 3 areas are flagged with a value and used in the measures as a condition, like below example:

My salesAll salesArea_codeArea_name
10.000100.0000Rural
40.000400.0001Urban
50.000500.0002Total

 

Example measure:

 

My_sales_rural =
CALCULATE (
    SUM ( 
        Table[Sum_My_Sales]), 
        Table[Area_code] = 0
)

 

 

In the report I'd like to be able to select in the slicer "rural" and then only see the line for rural market share, when selecting "total" only see the line for total market share.

mphillenga_0-1651168685996.png to this: mphillenga_1-1651168822640.png

 

 

I've tried dynamic measures, but that gives me one line instead of three when nothing or "all" is selected in the slicer. And I've tried SWITCH(), but that also did not work well.

 

Any ideas?

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @mphillenga ,

 

I created a exmalp pbix in the end you can refer.

 

With this measure and please modify it to suit your model.

Measure =
SWITCH(SELECTEDVALUE('Table'[Area_name]),
"Rural", [my_sale_rural],
"Urban", [my_sale_urban],
calculate([my_sale_urban],filter(all('Table'[Area_name]),[Area_name]="Rural" ||[Area_name]="Urban")
)
 

Best Regards

Community Support Team _ chenwu zhu

 

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
v-chenwuz-msft
Community Support
Community Support

Hi @mphillenga ,

 

I created a exmalp pbix in the end you can refer.

 

With this measure and please modify it to suit your model.

Measure =
SWITCH(SELECTEDVALUE('Table'[Area_name]),
"Rural", [my_sale_rural],
"Urban", [my_sale_urban],
calculate([my_sale_urban],filter(all('Table'[Area_name]),[Area_name]="Rural" ||[Area_name]="Urban")
)
 

Best Regards

Community Support Team _ chenwu zhu

 

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

Thanks a lot!

parry2k
Super User
Super User

 why you have this condition in your measure Table[Area_code] = 0

 

it is forcing it to filter for Area Name  = RURAL, if you remove this and everything should work, not sure what you are trying to achieve with this filter.

 

 

 

Follow us on LinkedIn and  to our YouTube channel

I would  Kudos if my solution helped. If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

👉

@mphillenga



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for your response @parry2k 

 

This condition is in the data because we calculate three measures. One for '0', one for '1' and one for '2'.

We want to be able to switch these on and off.

 

If you have any solutions, please let me know

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.