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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
julien310356
Frequent Visitor

Dynamically Filter Based on the Value selected

 

Hello,

I want to create two filters for two date columns (one representing the start year and the other representing the end year). I want to ensure that when I select a year in the start year filter, the choices available in the end year filter are greater than or equal to the selected start year. These columns are associated with query parameters. 

 

I tried creating a measure as follows:

YearInitialMin = MIN(YearInitialTable[Years])
IsValidEndYearMeasure =
var is_in_range = CALCULATE(COUNTROWS(YearEndTable),FILTER(YearEndTable,YearEndTable[Years]>=[YearInitialMin]))
return if(is_in_range>0,1,0)
 
Then, I applied this in the filter pane of my second graph, by filtering with IsValidEndYearMeasure is 1. 
 

However, I got this message: An incompatible filter is used on a column with a parameter mapping. 

I would appreciate your help.

3 REPLIES 3
v-heq-msft
Community Support
Community Support

Hi @julien310356 ,
Thanks for @amitchandak rerply.
It looks as if you already know the filtering logic, now you just need to place these two columns in two tables that are not related and create a measure as follows
Sample data

vheqmsft_0-1722923425246.png

vheqmsft_1-1722923432122.png

IsAfter = 
IF(
    SELECTEDVALUE('End Year'[End Year]) >= SELECTEDVALUE('Start Year'[Start Year]),
    1,
    0
)

Final output

vheqmsft_2-1722923496409.png

Best regards,
Albert He


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

 



Thanks for your solutions @amitchandak  and @v-heq-msft . I implemented it with some changes related to the needs of my projects (I need to have a specific date format like YYYY-MM). 

 

However, after creating the measure such as: 

isAfter = IF(VALUE(LEFT(SELECTEDVALUE('YYYY-MM (Initial)'[YYYY-MM]), 4)) < VALUE(LEFT(SELECTEDVALUE('YYYY-MM (End)'[YYYY-MM]), 4)), 1, 0)
 
I got the message: An incompatible filter is used with a parameter mapping. The problem is that I use a parameter in my column, as mentioned in my problem, and I think I can't use this type of solutions with this constraint. 
 
That's why I look for new solution, regarding parameter constraints (limitations on filters are on this link: Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn)
amitchandak
Super User
Super User

@julien310356 , refer if this approach can help

How to use two Date/Period slicers

https://youtu.be/WSeZr_-MiTg

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

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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