Forum Discussion
Comparison based on date filter
- 6 years ago
Hi Anonymous ,
Do you want to divide the number of Value in a period of time by the number of Value in a period of time before?
Maybe you can refer this measure, we change the SUM function to COUNT function.
Measure = var min_date = MIN('Date'[Date]) var max_date = MAX('Date'[Date]) var x = DATEDIFF(min_date , max_date,DAY) var last_x_date = min_date - x var max_date_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=max_date)) var min_date_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=min_date)) var last_x_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=last_x_date)) var difference_1 = max_date_value - min_date_value var difference_2 = min_date_value - last_x_value return DIVIDE(difference_1 , difference_2)If it doesn’t meet your requirement, could you please show the exact expected result based on the pbix that we have shared?
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.
BTW, pbix as attached.
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.
v-zhenbw-msft : It doesn't give the output. Here's the expected output based on your PBI file.
If in the date filter I select 1/7/2020 to 1/9/2020 which means 3 days...then the KPI should show the % different based on the count of values from 1/7/2020 to 1/9/2020 and 1/4/2020 and 1/6/2020 (going back three days). Basically the idea is to check the % difference of counts in the timeframe selected and going back the same timeframe before.
If I would have selected 1/7/2020 to 1/8/2020 then the count % difference would be from 1/7/2020 to 1/8/2020 and 1/6/2020 and 1/7/2020
Hi Anonymous ,
Do you want to divide the number of Value in a period of time by the number of Value in a period of time before?
Maybe you can refer this measure, we change the SUM function to COUNT function.
Measure =
var min_date = MIN('Date'[Date])
var max_date = MAX('Date'[Date])
var x = DATEDIFF(min_date , max_date,DAY)
var last_x_date = min_date - x
var max_date_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=max_date))
var min_date_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=min_date))
var last_x_value = CALCULATE(COUNT('Table'[Values]),FILTER('Table','Table'[Date]=last_x_date))
var difference_1 = max_date_value - min_date_value
var difference_2 = min_date_value - last_x_value
return
DIVIDE(difference_1 , difference_2)
If it doesn’t meet your requirement, could you please show the exact expected result based on the pbix that we have shared?
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.
BTW, pbix as attached.
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.