cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
klllmmm
Regular Visitor

How create a combined slicer using several fields

I have a data table with several columns that you want to use to create a slicer, where if the selected value is found in any of such columns, then such a line has to appear.

 

klllmmm_0-1668937299318.png

For example, I want to create a slicer with a list Key of options "A", "B" & "C".
When the user selects any or multiple items from the slicer such line items containing 1 in those respective columns have to appear.
If the user selects/ticks slicer options A & B, then A, D, F, & G rows should appear.
https://1drv.ms/u/s!An03iU493hAgnpwhuu6i7Rs59CXiRw?e=6NZnKv 

Can someone help me how to achieve this?

 

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

Hi  @klllmmm ,

 

Here are the steps you can follow:

1. Power Query – Copy Table1 to form Table2..

vyangliumsft_0-1669107973980.png

2. Select – [Key_A], [Key_B], [Key_C] – Unpivot Columns.

vyangliumsft_1-1669107973983.png

Result:

vyangliumsft_2-1669107973985.png

3. Create column calculated.

Slicer table =
DISTINCT('Table2'[Attribute])

vyangliumsft_3-1669107973986.png

4. Create measure.

Flag =
var _select=SELECTCOLUMNS('Slicer table',"1",[Attribute])
return
IF(
    MAX('Table'[Category]) in
SELECTCOLUMNS(FILTER(ALL('Table2'),'Table2'[Attribute] in _select),"2",[Category]) ,1,0)

5. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_4-1669107973987.png

6. Result:

vyangliumsft_5-1669107973988.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @klllmmm ,

The SELECTCOLUMN function refers to saving the returned results to form a table, where "2" is a column name of the table, you can choose any name.

Refer to:

SELECTCOLUMNS function (DAX) - DAX | Microsoft Learn

IF(
    MAX('Table'[Category]) in
SELECTCOLUMNS(FILTER(ALL('Table2'),'Table2'[Attribute] in _select),"2",[Category]) ,1,0)

This function represents:

When the data in column [Category] exists in column [2] formed using the SELECTCOLUMN function, 1 is returned, otherwise 0.

 

Best Regards,

Liu Yang

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

v-yangliu-msft
Community Support
Community Support

Hi  @klllmmm ,

 

Here are the steps you can follow:

1. Power Query – Copy Table1 to form Table2..

vyangliumsft_0-1669107973980.png

2. Select – [Key_A], [Key_B], [Key_C] – Unpivot Columns.

vyangliumsft_1-1669107973983.png

Result:

vyangliumsft_2-1669107973985.png

3. Create column calculated.

Slicer table =
DISTINCT('Table2'[Attribute])

vyangliumsft_3-1669107973986.png

4. Create measure.

Flag =
var _select=SELECTCOLUMNS('Slicer table',"1",[Attribute])
return
IF(
    MAX('Table'[Category]) in
SELECTCOLUMNS(FILTER(ALL('Table2'),'Table2'[Attribute] in _select),"2",[Category]) ,1,0)

5. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_4-1669107973987.png

6. Result:

vyangliumsft_5-1669107973988.png

 

Best Regards,

Liu Yang

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

Thank you so much for this answer!!!

One more thing. 

In the step no 4, SELECTCOLUMN function what is referred from "2" ? 

daXtreme
Super User
Super User

Such problems have been solved on this forum countless times. Please use the Search box to find them. Also, on YT there are vids (some by Alberto Ferrari) that show how to use a slicer to get the OR semantics instead of AND (because this is what you're actually asking for).

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.