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
Anonymous
Not applicable

DAX Filter

Hello,

 

I have created a report that is missing filter column to use in the slicer:

Filter column looks as below:

ItemResult
AA and AB
B B and AB
CC
ABAB

 

There is a filter column "Item" that should be used in the slicer. Logic is: if A selected then slicer should include A and AB, if B selected then (B and AB), for C = C and for AB =AB. 

 

I tried to use IF and SWITCH functions but only achived either A with AB or B with AB.

Please help. 

2 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

Hi @Anonymous 

 

Your request is a little bit tricky😎 .

Please download this file and I hope this cover all your requirements: https://gofile.io/d/Ta9o4y

 

Output:

VahidDM_0-1636591900961.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

View solution in original post

v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can clearly understand your requirement, I think you can achieve this using a calculated table for the slicer and a measure as the flag for the visual filter, you can try my steps:

  1. Create a table like this:
Slicer = 'Table'
  1. Create a measure like this:
Flag =

var _selected=SELECTEDVALUE(Slicer[Item])

return

SWITCH(

    _selected,

    "A",IF(MAX('Table'[Item]) in {"A","AB"},1,0),

    "B",if(MAX('Table'[Item]) in {"B","AB"},1,0),

    "C",IF(MAX('Table'[Item])="C",1,0),

    "AB",IF(MAX('Table'[Item])="AB",1,0)

)

Then you can create a slicer and a table chart to place the visual filter like this:

vrobertqmsft_0-1636710399924.png

 

And you can get what you want.

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

6 REPLIES 6
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can clearly understand your requirement, I think you can achieve this using a calculated table for the slicer and a measure as the flag for the visual filter, you can try my steps:

  1. Create a table like this:
Slicer = 'Table'
  1. Create a measure like this:
Flag =

var _selected=SELECTEDVALUE(Slicer[Item])

return

SWITCH(

    _selected,

    "A",IF(MAX('Table'[Item]) in {"A","AB"},1,0),

    "B",if(MAX('Table'[Item]) in {"B","AB"},1,0),

    "C",IF(MAX('Table'[Item])="C",1,0),

    "AB",IF(MAX('Table'[Item])="AB",1,0)

)

Then you can create a slicer and a table chart to place the visual filter like this:

vrobertqmsft_0-1636710399924.png

 

And you can get what you want.

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

Anonymous
Not applicable

That was perfect, thank you for your help @v-robertq-msft.

VahidDM
Super User
Super User

Hi @Anonymous 

 

Your request is a little bit tricky😎 .

Please download this file and I hope this cover all your requirements: https://gofile.io/d/Ta9o4y

 

Output:

VahidDM_0-1636591900961.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

Anonymous
Not applicable

Thanks @VahidDM but for some reason I am not able to download the file.  

Watsky
Solution Sage
Solution Sage

Hi @Anonymous 

How about 

IF(CONTAINSSTRING('Table'[Result],'Table'[Item])= TRUE,'Table'[Item],"")

Watsky_0-1636587414152.pngWatsky_1-1636587425193.png

Watsky_2-1636587433767.pngWatsky_3-1636587444617.png

 

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

Hi @Watsky thanks for helping. 

Sorry if I get it wrong but there is no column called "Result" in my table, I just illustrated as an example in my question. There is only one column "Item" to filter and I want to have custom column as "Result". 

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.

Top Solution Authors