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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
DustinD
Helper I
Helper I

Date filters in dax

I have a issue i can not figure out in dax. i have 2 date fields in my report. i will try my best to explain the issue. so date1 is a snap shot evrey monday and thursday. date2 is the last time a part was moved. what im trying to do in dax is make something that will only bring in date2 if its 5 days older then date1. i also want this to be dynamic. for example lets say they select date1 from 3 weeks ago. i want it to only bring in date2 if its 5 days older then the selected date. so in this case 5 days older then date1 from 3 weeks ago. thanks for the help.

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Test data:

ValtteriN_0-1696571852220.png

 

ValtteriN_1-1696571862955.png

 

Dax:

Test if older than 5 =
var _lastmoved = MAX('Table (3)'[LastMoved])
var _datediff = DATEDIFF(MAX('Table (2)'[SnapShotDate]),_lastmoved,DAY) return
IF(_datediff<=-5,1,0)



Now place this measure as a filter like this:

ValtteriN_2-1696572382924.png

 

Now the dates displayed are only the ones where the part was moved more than 5 days ago. E.g. 29.9.2023 is not shown since the last moved was 24.9.2023 -> within 4 days of the date.

You can apply further filters and the logic will work the same.


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Test data:

ValtteriN_0-1696571852220.png

 

ValtteriN_1-1696571862955.png

 

Dax:

Test if older than 5 =
var _lastmoved = MAX('Table (3)'[LastMoved])
var _datediff = DATEDIFF(MAX('Table (2)'[SnapShotDate]),_lastmoved,DAY) return
IF(_datediff<=-5,1,0)



Now place this measure as a filter like this:

ValtteriN_2-1696572382924.png

 

Now the dates displayed are only the ones where the part was moved more than 5 days ago. E.g. 29.9.2023 is not shown since the last moved was 24.9.2023 -> within 4 days of the date.

You can apply further filters and the logic will work the same.


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




 @ValtteriN I was able to make this work after doing some changes. thanks for help.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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