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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.