Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hey there,
I would like to create a measure for dynamically calculating the last period. I am using this calendar slicer:
The measure should be something like:
vs Last Period = CALCULATE(SUM(Forms[Ocurrences]), DATEADD('Calendar'[Date],-60,DAY)) Yet, the time period should be dynamic not 60 days before.
To give an example:
Looking forward to any suggestions!
Solved! Go to Solution.
Hi @Anonymous,
'Table' means the fact table you used to calculate, the 'selector' means the date table you used. For my expression, it is calculated based on selected range day counts. (filter range equal to 'previous N[day count of selected date range] day of current date' to 'current date')
Hope the above helps you to clarify my expression and calculation logic.
Regards,
Xiaoxin Sheng
Hi @Anonymous,
You can create a new table to extract the raw table date value and use it as the source of the slicer. (it does not have a relationship to raw table fields)
Then you can use the following measure formula based on selection range to calculate the rolling total on each row:
Measure =
VAR currDate =
MAX ( 'Table'[Date] )
VAR range =
COUNTROWS ( ALLSELECTED ( 'Selector'[Date] ) )
RETURN
CALCULATE (
SUM ( 'Table'[Amount] ),
FILTER (
ALLSELECTED ( 'Table' ),
[Date] >= currDate - range
&& [Date] <= currDate
)
)
Regards,
Xiaoxin Sheng
I am not exactly sure what you mean by the first sentence. Could you elaborate a bit? Maybe even show a step-by-step guide? I can't really figure out what you used as Select (Date). Just to double check you used my original date table as Table(Amount), right?
Hi @Anonymous,
'Table' means the fact table you used to calculate, the 'selector' means the date table you used. For my expression, it is calculated based on selected range day counts. (filter range equal to 'previous N[day count of selected date range] day of current date' to 'current date')
Hope the above helps you to clarify my expression and calculation logic.
Regards,
Xiaoxin Sheng
@Anonymous I think we need to do some trick here to make it work as there is no way to find out what is selected in the relative date filter. Can you share a sample pbix file thru one drive/google drive and will try to work thru some solutions. Cheers!!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 50 | |
| 43 |