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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
a11smiles
New Member

Joining and Filtering

Let's say I have three tables:

 

Food Table (Coming from OData service):

 

IDFood
1Apple
2Orange
3Lettuce
4Carrot
5Grape

 

I also have two reference tables:

 

Fruits

ID
1
2
5

 

 

Vegetables

ID
3
4

 

 

 

Problem/Goal:

 

On my report page, I have a table of all the food.  I'd like to create a slicer that allows me to toggle showing only fruit or vegetables or both. This is a contrived set of data, but the real data set may have items that fall into both subcategories (e.g. with a table with colors, if one chose "orange," then both orange and carrot would be visible).

 

I could fill my table with bits such as:

 

IDFoodFruitVegetableOrangeRedGreen
1Apple1  1 
2Orange1 1  
3Lettuce 1  1
4Carrot 11  
5Grape1   1

 

So, how do I create a "Slicer" with various options such as, fruit, vegetable, orange, red, and green to filter? Or, am I going about this the wrong way?

 

Thanks!

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

Hi @a11smiles ,

 

1 Create a table for slicer contains fruit,vegetable,orange, red and green.

2 Create a matrix table then ID, Food in the rows and options in the columns.

3 Create a measure like this:

Measure =
VAR _1 =
    SELECTEDVALUE ( 'Food Table'[ID] )
RETURN
    SWITCH (
        SELECTEDVALUE ( Slicer[options] ),
        "fruit", IF ( _1 IN VALUES ( Fruits[ID] ), 1 ),
        "vegetable", IF ( _1 IN VALUES ( Vegetables[ID] ), 1 ),
        "red", IF ( _1 IN VALUES ( Red[ID] ), 1 ),
        "orange", IF ( _1 IN VALUES ( Orange[ID] ), 1 ),
        "green", IF ( _1 IN VALUES ( Green[ID] ), 1 )
    )

 

Result:

vchenwuzmsft_0-1657785783572.gif

Pbix in the end you can refer.

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

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @a11smiles ,

 

1 Create a table for slicer contains fruit,vegetable,orange, red and green.

2 Create a matrix table then ID, Food in the rows and options in the columns.

3 Create a measure like this:

Measure =
VAR _1 =
    SELECTEDVALUE ( 'Food Table'[ID] )
RETURN
    SWITCH (
        SELECTEDVALUE ( Slicer[options] ),
        "fruit", IF ( _1 IN VALUES ( Fruits[ID] ), 1 ),
        "vegetable", IF ( _1 IN VALUES ( Vegetables[ID] ), 1 ),
        "red", IF ( _1 IN VALUES ( Red[ID] ), 1 ),
        "orange", IF ( _1 IN VALUES ( Orange[ID] ), 1 ),
        "green", IF ( _1 IN VALUES ( Green[ID] ), 1 )
    )

 

Result:

vchenwuzmsft_0-1657785783572.gif

Pbix in the end you can refer.

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors