The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
Solved! Go to Solution.
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] ) )
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.
No problem. Glad you were able to get it to work. The built-in time intelligence functions are pretty handy
User | Count |
---|---|
65 | |
59 | |
55 | |
54 | |
32 |
User | Count |
---|---|
180 | |
88 | |
70 | |
46 | |
45 |