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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
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.