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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
oaz18
New Member

Filter within if statement

Hi, 

I'm a bit stuck on how to filter a Show-hide measure I created. To give some context, I have a slicer with the following selections: Georgia and Florida. The slicer is connected to a graph that shows diabetes incidence rates for "Florida" or "Georgia" based on age groups depending on the selection in the slicer.

 

Additionally, I have a cards that show incidence rates for Florida or Georgia based on the age groups. When Georgia is selected, I wanted the card for "14 and under" to come up blank so I created the Show-hide measure shown below to do this. I formatted the specific card to show white font when Georgia is selected, since the background is white, the card looks blank.

 

ShowHide Graph State= if(selectedvalue(slicer_DoseSelector[Column1]) = "Georgia",1,0)

 

Up until this point the graph with the slicer and "14 and under" card work perfectly.

 

 Now I have to update the graph to exclude the "4 years and under" age group if "Georgia" is selected. I thought it may be possible to do this by using a similar measure and adding a filter statement so I tried the measure below: ShowHide Graph Age. I'm not sure if there is a better approach to filter out a specific age group in a graph based on a slicer selection.

 
Measure with filter (not working - "the syntax is incorrect"):
ShowHide Graph Age= if(selectedvalue(slicer_DoseSelector[Column1]) = "Georgia",1,0), FILTER('age bracket'[bracket]='4 years and under')
 
If anyone can help me learn the correct way to add a filter, I would greatly appreciate it!
1 ACCEPTED SOLUTION
AlB
Super User
Super User

@oaz18 

If I understand correctly, you  will have to modify the measure you are using in the graph to show the data rather than adding a "ShowHide" measure. The use case is different from the one in the card visual, since here we are talking about modifying the result instead of showing it or not. 

Can you show the code for the main measure in the chart? Plus the structure of the relevant tables involved in that measure.

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

4 REPLIES 4
AlB
Super User
Super User

@oaz18 

If I understand correctly, you  will have to modify the measure you are using in the graph to show the data rather than adding a "ShowHide" measure. The use case is different from the one in the card visual, since here we are talking about modifying the result instead of showing it or not. 

Can you show the code for the main measure in the chart? Plus the structure of the relevant tables involved in that measure.

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Thank you for all your help! I modified the measure I'm using in the graph by adding a filter to it and that did the trick. Thanks again!

AlB
Super User
Super User

Hi @oaz18 

There are several major issues with the syntax of that code.

In any case, I would need first to understand what you want to do. What do you mean exactly by "I'd like to add a filter so anyone 4 years and under is also removed. This measure is then used to filter a graph. "

Removed from where?

What do you mean by a measure filtering a graph?

Can you provide an example based on sample data to elaborate on the requirements? Include the expected result.

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Thank you for your help and apologies for not being more clear. I updated the post with more details on the issue I'm stuck. I hope it's a little clearer this time. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors