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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Farhad88
Helper I
Helper I

Filtering a slicer's values based on the values of another table

Hi everybody!


My goal is to filter the values of a slicer, based on the values selected from another table.

 

Problem description:

I have a slicer which shows the values of a dynamic parameter (named Y1-Axis Params) as the following:

Farhad88_0-1707072005064.png

 

The dynamic parameter (named Y1-Axis Params) is defined as the following.  So, in the table view, you should see three columns as the following:

Farhad88_1-1707072049983.png

 

And, I have another table (named: Table_Params_List) which contains the Id and name of some parameters, as the following:

Farhad88_2-1707072108899.png

 

I want to filter the slicer’s values based on the selected values from this table, so:

1- first I defined a measure to return the Id of the selected value:

Selected_ParamId = SELECTEDVALUE(Table_Params_List[Id],0)

 

2- then, I used a custom column to save the Id of all selected values:

Selected_ParamIDs =

 var _selectedIDs= [Selected_ParamId]

 return

 _selectedIDs

 

So far so good. Now Selected_ParamIDs shows the IDs of all selected rows from Table_Params_List:

Farhad88_3-1707072201936.png

Now, I want to filter the slicer’s values based on the values of this custom column. For this purpose:

I defined a new measure (named: Include?) as the following:

 

Include? =

var _selectedIDs= VALUES(Table_Params_List[Selected_ParamIDs])

return

IF(

    MAX('Y1-Axis Params'[Y=Axis Params Order]) in _selectedIDs,

    1,   0)

 

And then, I added this measure (using dag and drop) to the Filters pan of the slicer visual and configed it as the following:

Farhad88_4-1707072250412.png

As you can see, in this way, I could get the IDs of the selected items from the table, but the slicer still shows all of the values!

 

** But, if I use a measure as the following, it works well and filters the values of the slicer!!

Include? =

IF(

    MAX('Y1-Axis Params'[Y=Axis Params Order]) >= 2 ,

    1,   0)

 

So why it doesn’t work when I try to use the variable _selectedIDs? (But it works if I use some fixed values for the comparison!)

 

Any advice is very appreciated!

Thanks and best regards!

Farhad

6 REPLIES 6
Farhad88
Helper I
Helper I

Dear Power BI experts,

@amitchandak @Anonymous 

This issue is still open 😑. I have included the pbix file with the problem description in previous posts.

Any solution or suggestion is highly appreciated! 🙂

 

Best regards,

Farhad

Anonymous
Not applicable

Hi, @Farhad88 

 

Perhaps you can create a new table that will be based on the selected values in the Table_Params_List

 

vyohuamsft_0-1707120082449.png

 

Selected_Params =

CALCULATETABLE(

    FILTER(Table_Params_List,[Selected_ParamIDs]=1))

 

Modify the measure Include? to use the newly created table to determine whether a value should be included in the slicer.

 

vyohuamsft_1-1707120082450.png

 

Include? =

VAR _selectedParamOrder = MAX('Y1-Axis Params'[Y=Axis Params Order])

RETURN

IF(_selectedParamOrder IN VALUES(Selected_Params[Id]),1,0)

 

 

Apply the measure as a filter to the slicer.

1.1.png

 

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

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

 

Dear @Anonymous,

Many thanks for your reply. But it dosen't work unfortunately. 

 

I have provided more details, also the pbix files, in the following two posts (I don't duplicate them here just to prevent overcrowding the topic).

I look forward to hearing your further suggestions!

 

Best regards,

Farhad 

Dynamic Slicer.pbix

Dynamic Slicer 2.pbix

amitchandak
Super User
Super User

@Farhad88 , measure seem good, Try this version and check for not blank

 

countrows(intersect( Values('Y1-Axis Params'[Y=Axis Params Order]),VALUES(Table_Params_List[Selected_ParamIDs])))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Dear @amitchandak and @Anonymous,

Thanks for your suggections.

I tried them out, but they were not promising, unfortunately.

As I showed in the following screenshot, I can get the Id of the selected values from the table, but when I try to filter the slicer based on these IDs (using the "Include?" measure) it doesn't work:

Farhad88_0-1707139924198.png

I also attached the Dynamic Slicer.pbix file for further investigations.

Thanks and best regards,

Farhad

 

I noticed that if we convert the slicer to a table visual everything works well! (screenshot and pbix file attached)

 

So, why the same code and settings work differently for slicer and table visuals?

And, more importantly, the same question remines: 

How we can filter the slicer's values dynamically based on the selected values of another table?

 

Dynamic Slicer 2.pbix

Thanks for your advice!

Farhad88_0-1707213308234.png

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors