Forum Discussion
Measure for a Change % KPI, based on two dynamic date ranges
- 5 years ago
HansTheEnforcer , Based on what I got.
Refer to my blog , I think very similar Item was disucussed
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Hi HansTheEnforcer ,
Do you want to calculate a date range divided by a date range thirty days ago?
For example, if you select 2020/2/19 – 2020/2/21, then it will calculate the value in 2020/2/19-2020/2/21 divide the value in2020/2/19 minus 30 days – 2020/2/21 minus 30days.
If yes, we can create a date table and a measure to meet your requirement. (Note: date table has no relationship.)
Measure =
var _min_date = MIN('Date'[Date])
var _max_date = MAX('Date'[Date])
var _min_date_30 = _min_date-30
var _max_date_30 = _max_date-30
return
DIVIDE(
CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]>=_min_date_30 && 'Table'[Date]<=_max_date_30))-
CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]>=_min_date && 'Table'[Date]<=_max_date)),
CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]>=_min_date && 'Table'[Date]<=_max_date)))
If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data or describe the fields of each tables and the relations between tables simply?
It will be helpful if you can show us the exact expected result based on the tables.
Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.