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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to create a custom SLICER?

Hello

 

I have two sets of criteria, e.g.:

CriteriaSet1:

Col1 = A || Col2 <> B && Col3 = C

CriteriaSet2:

Col1 = D || Col2 <> E && Col3 = F

 

I want to use these criteria to filter a table. I then want to create a slicer which will have two values: CriteriaSet1 and CriteriaSet2.

 

When I select each of these values, I want to apply the respective criteria.

 

How can I do that? Do I need to create Measures, Tables or anything else? Please explain in your answer instead of just saying CriteriaSet1 = .... without explaining what that is.

 

Thanks!

10 REPLIES 10
Anonymous
Not applicable

Hi @Anonymous ,

 

You will need to create a new table with couluns contains measures' name.

Use this table as slicer with following measure.

Measure = SWITCH(SELECTEDVALUE('Table (2)'[slicer]),"sum",[sum],"avg",[avg])

Sample data for your reference.

1.PNG

2.PNG 

 

Best Regards,

Jay

Anonymous
Not applicable

@Anonymous  thanks but can you tell me please what is the below and how do I create it? 

'Table (2)'[slicer]

 

Thanks! 

Anonymous
Not applicable

Hi @Anonymous ,

 

It's a simple table contains measures' name as the slicer.

Pbix as attached, hopefully works for you.

 

Best Regards,

Jay

Anonymous
Not applicable

@Anonymous thanks but unfortunately I cannot open your test.pbix, it displays an error and it closes

 

From what I understand, I will need to create both one table and one measure, is that right?

 

Can you paste please the code for the two and I will try to figure out.

 

Thanks!

Anonymous
Not applicable

@Anonymous 

 

I get this error:

 

Feedback Type:
Frown (Error)

Error Message:
Object reference not set to an instance of an object.

Anonymous
Not applicable

@Anonymous 

 

Sorry I still do not understand what you are doing.

 

I have a table already that I want to apply the filter on.  I do not want to create another table. If I do need to create another table, I do not want it to be visible.

 

So I already have the table:

A, A1

B, B2

C, C3

D, D2

E, E3

 

I only want to create a slicer visual.

The slicer visual will need to have two values.

One value is: Show the Table rows where Col2 contains "2"

The second value is: Show the Table rows where Col2 contains "1"

 

These are the only filters I want to be visible in the slicer visual.

 

Can you advise what I need to do step by step please, assuming nothing as known?

 

Thanks!

Anonymous
Not applicable

Hi @Anonymous ,

 

avgx = AVERAGEX(ALL('Table'),'Table'[Column2])

sumx = SUMX(ALL('Table'),'Table'[Column2])

Measure = SWITCH(SELECTEDVALUE('Table (2)'[slicer]),"sum",[sumx],"avg",[avgx])

Table2 is a sample table which i create manually use Enter Data feature.

 

Best Regards,

Jay

amitchandak
Super User
Super User

@Anonymous , In case you need as in filter.

calculate([measure], filter(Table,(Col1 = D || Col2 <> E && Col3 = F) && (Col1 = A || Col2 <> B && Col3 = C)))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

 

Thanks, can you elaborate how do I use that? Also what is the [measure] you mention?

parry2k
Super User
Super User

@Anonymous add a new custom column with the logic you want and use that for the slicer

 

New Column =
IF ( <condition1>, "Criteria 1", 
IF ( <condition2>, "Criteria 2",
"Unknown"
) )

 

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

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.