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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Creating a slicer that groups together values from a column

Hi,

I am trying to create a slicer that groups together various items in one column from an exisiting table.

For example, if my existing table contains a column "Food" like so:

Food
Strawberries
Carrots
Cucumbers
Cake
Banana
Orange

I would like to create a slicer with 3 options, Fruit, Vegetables and Dessert, where Fruit filters my dashboard to rows containing "Strawberries", "Banana" and "Orange, Vegetables filters to rows containing "Carrots" and "Cucumbers", and Desserts filters to rows containing "Cake".

 

Thanks

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

You could add a conditional column in Power query for a new column

OR

create a new table to use as the slicer using:

 

 

 

Slicer =
VAR Dessert =
    ADDCOLUMNS (
        CALCULATETABLE ( VALUES ( OriginalTable[Food] ), OriginalTable[Food] = "Cake" ),
        "Type", "Dessert"
    )
VAR Vegetables =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( OriginalTable[Food] ),
            OriginalTable[Food] IN { "Cucumbers", "Carrots" }
        ),
        "Type", "Vegetables"
    )
VAR Fruit =
    ADDCOLUMNS (
        EXCEPT (
            VALUES ( OriginalTable[Food] ),
            UNION (
                CALCULATETABLE ( VALUES ( OriginalTable[Food] ), OriginalTable[Food] = "Cake" ),
                CALCULATETABLE (
                    VALUES ( OriginalTable[Food] ),
                    OriginalTable[Food] IN { "Cucumbers", "Carrots" }
                )
            )
        ),
        "Type", "Fruit"
    )
RETURN
    UNION ( Dessert, Vegetables, Fruit )

 

 

 

foods.jpg

 

Or Create a copy of the table (Modeling -> New Table) and type Slicer = 'OriginalTable'
Then 

Ftypes.gif

 

Then create a 1:* relationship between the food fields in both tables. 

ftype model.jpg

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

You could add a conditional column in Power query for a new column

OR

create a new table to use as the slicer using:

 

 

 

Slicer =
VAR Dessert =
    ADDCOLUMNS (
        CALCULATETABLE ( VALUES ( OriginalTable[Food] ), OriginalTable[Food] = "Cake" ),
        "Type", "Dessert"
    )
VAR Vegetables =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( OriginalTable[Food] ),
            OriginalTable[Food] IN { "Cucumbers", "Carrots" }
        ),
        "Type", "Vegetables"
    )
VAR Fruit =
    ADDCOLUMNS (
        EXCEPT (
            VALUES ( OriginalTable[Food] ),
            UNION (
                CALCULATETABLE ( VALUES ( OriginalTable[Food] ), OriginalTable[Food] = "Cake" ),
                CALCULATETABLE (
                    VALUES ( OriginalTable[Food] ),
                    OriginalTable[Food] IN { "Cucumbers", "Carrots" }
                )
            )
        ),
        "Type", "Fruit"
    )
RETURN
    UNION ( Dessert, Vegetables, Fruit )

 

 

 

foods.jpg

 

Or Create a copy of the table (Modeling -> New Table) and type Slicer = 'OriginalTable'
Then 

Ftypes.gif

 

Then create a 1:* relationship between the food fields in both tables. 

ftype model.jpg

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@Anonymous , Create  a new column and use that in the slicer

 

Switch( True() ,

[food] in {"Strawberries", "Banana" ,"Orange"} , "Fruit",

[food] in {"Strawberries", "Carrots" ,"Cucumbers"} , "Vegetables ",

"Desserts"

)

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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