Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Best way to filter on 2 dates?


I'm trying to do my best to filter on 2 sets of Years, but having a hard time with the dax. Not sure if this is a CALCULATE, or FILTER? Essentially, I want to have it so when the Year filter is 2022, it will filter for both YearID = 2022 & BudgetYear = 2022.


In the example below, when Year = 2022, only Project A & Project F should show.

when Year = 2021, Project C & Project D should show

when Year = 2020, nothing should show, etc


20222022Project A
20222021Project B
20212021Project C
20212021Project D
20202021Project E
20222022Project F
20222023Project G



Super User
Super User


This is the approach you should follow.  Create calculated column formulas to make 2 date columns (YearID_Date and BedgetYear_Date) from the Year columns you have (the date could be day 1 and month 1 of those years).  Create a Calendar Table and write a calculated column formula to extract Year.  Create a relationship (Many to One and Single) from the YearID_Date column to the Date column of the Calendar Table.  Create a Table/matrix visual and drag Title there.  Create a Year slicer from the Calendar Table and select 2022.  Write this measure

Measure = calculate(countrows(Data),filter(Data,Data[YearID_date]=Data[BudgetYear_Date]))

Hope this helps.

Ashish Mathur
Community Support
Community Support

HI @shinney,

It sounds like you want to achieve the custom filter effect.

For this scenario, I'd like to suggest you write a measure formula to compare current value and both two fields value and return flag. Then you can use this formula on visual level filter to filter records.

Applying a measure filter in Power BI - SQLBI

Using the SELECTEDVALUE function in DAX - SQLBI


Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi Xiaoxin,


Thanks for the reply. I'm still not really understanding how SELECTEDVALUE here would apply. Also, what do you mean by the return flag? None of the DAX measures I've tried remotely works

Helpful resources

T-Shirt Design Challenge 2023

Power BI T-Shirt Design Challenge 2023

Submit your creative T-shirt design ideas starting March 7 through March 21, 2023.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors