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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Filter Date Range using IF condition

Hi all,

Is there any way we can restrict the dates from the Date Column in my data based on the conditions i.e., by using IF condition?
If yes, please provide me the DAX syntax.

A small illustration like:
IF(a>b, Dates> x && Dates <y)

Thanks in advance 🙂
Kashyap.

3 REPLIES 3
amitchandak
Super User
Super User

If you want to use in If and in the measure then you need use some aggregation

 

IF(a>b, Max(Dates)> x && max(Dates) <y)

 

if you in the filter you can avoid max on a date if X and Y are static

 

What you have done is possible in the column

 

refer example on my blog

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...

 

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
Anonymous
Not applicable

Thanks for the response @amitchandak 
Also, I have a table visual on which I need to filter a specific range of dates based on the selection in another date slicer, how can we do it?
I have my main table(T1) with columns including Date column, I created a duplicate of the T1 as T2 and removed every column except Date column. So when I select a value from the date column in T2, I need to get the data from the SelectedDate till SelectedDate-30 in a table visual which contains the columns from T1.
How can we achieve this ?

Thanks
Kashyap.

hi  @Anonymous 

When you create a measure add this conditional in the formula as below:

eg.

Measure = CALCULATE(SUM('Table 1'[value]),FILTER('Table 1','Table 1'[Date]>=MAX('Table 2'[Date])-30&&'Table 1'[Date]<=MAX('Table 2'[Date])))
 
In this simple sample, I will show the data from the SelectedDate till SelectedDate-7
1.JPG
and here is sample pbix file, please try it.
 
Regards,
lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.