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
FinanceBI
Frequent Visitor

Set a starting point for a new measure using relative dates

Hi All, 

 

I'm looking to create a new measure that filters for the last 90 days starting 90 days from the current date. For, example, today is 4/24/2019, I'd like to be able to create a relative date filter that only counts balances from 10/24/2018 to 1/24/2019 (out of laziness I'm pretending every month has 30 days). 

 

I'm thinking I need to do this using DAX, can anyone point me in the direction of an answer?

 

Thank you,

 

Chris

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Assuming you have a Date table in your model and it is marked as such, I think the following should work. 

90 DAYS AFTER = 
IF(
    HASONEVALUE('Date'[Date]),
    DATEADD('Date'[Date], 90, DAY)
)

90 DAYS PRIOR = 
IF(
    HASONEVALUE('Date'[Date]),
    DATEADD('Date'[Date], -90, DAY)
)

Total Sales 90 Days = 
CALCULATE( 
    [Total Sales],  
  DATESBETWEEN(
        'Date'[Date],
           [90 DAYS PRIOR],
           [90 DAYS AFTER]
    )
)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Assuming you have a Date table in your model and it is marked as such, I think the following should work. 

90 DAYS AFTER = 
IF(
    HASONEVALUE('Date'[Date]),
    DATEADD('Date'[Date], 90, DAY)
)

90 DAYS PRIOR = 
IF(
    HASONEVALUE('Date'[Date]),
    DATEADD('Date'[Date], -90, DAY)
)

Total Sales 90 Days = 
CALCULATE( 
    [Total Sales],  
  DATESBETWEEN(
        'Date'[Date],
           [90 DAYS PRIOR],
           [90 DAYS AFTER]
    )
)

Perfect! Thanks, Nick!

 

I had to change the -90 to -180, otherwise, that worked as I had hoped.  That was more of an issue with how I worded the question though. 

Anonymous
Not applicable

No problem. Glad you were able to get it to work. The built-in time intelligence functions are pretty handy

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors