Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have historized monthly data for customer accounts and I would need to build a measure that calculates the Delta for any period defined by the user.
My data looks like this:
CustomerID | Date | Accumulated costs |
1 | 31.3.2019 | 100 |
1 | 30.4.2019 | 100 |
1 | 31.5.2019 | 150 |
1 | ... | ... |
2 | 31.3.2019 | 100 |
2 | 30.4.2019 | 200 |
2 | 31.5.2019 | 200 |
2 | ... | ... |
From this data a bunch of measures are calculated, summing up Accumulated costs based on different attributes of the customer.
The desired functionality is that the user selects a start date and an end date in a slicer (based on attribute Date in data above) and Power BI calculates the delta (change) in accumulated costs between those dates.
How could Power BI dynamically calculate the delta for any given period defined by the user?
Thanks for the help!
Solved! Go to Solution.
Hi @Anonymous ,
This is because I use the ALL() function, we can change it like below:
Delta = CALCULATE ( SUM ( Data[Accumulated costs] ), FILTER ( ALL (Data[Date] ), Data[Date] >= SELECTEDVALUE ( 'start date'[Date] ) && Data[Date] <= SELECTEDVALUE ( 'end date'[Date] ) ) )
Change the all (data) to ALL (Data[Date] )
Best Regards,
Teige
Hi @Anonymous ,
In your scenario, we can create two calendar tables for the start and end date slicer, then create the following measure:
Delta = CALCULATE ( SUM ( Data[Accumulated costs] ), FILTER ( ALL ( Data ), Data[Date] >= SELECTEDVALUE ( 'start date'[Date] ) && Data[Date] <= SELECTEDVALUE ( 'end date'[Date] ) ) )
The result will like below:
Best Regards,
Teige
Hi @TeigeGao ,
Thanks for the help!
One issue with your solution:
For some reason created Delta measure is not allocated correctly into columns in my Matrix visual, all columns show the total delta.
Delta should be allocated by attribute Location. See data below and screenshot of how delta is not allocated.
CustomerID | Date | Accumulated costs | Location |
1 | 31.3.2019 | 100 | A |
1 | 30.4.2019 | 100 | A |
1 | 31.5.2019 | 150 | A |
2 | 31.3.2019 | 100 | B |
2 | 30.4.2019 | 200 | B |
2 | 31.5.2019 | 200 | B |
3 | 31.3.2019 | 50 | C |
3 | 30.4.2019 | 50 | C |
3 | 31.5.2019 | 50 | C |
Hi @Anonymous ,
This is because I use the ALL() function, we can change it like below:
Delta = CALCULATE ( SUM ( Data[Accumulated costs] ), FILTER ( ALL (Data[Date] ), Data[Date] >= SELECTEDVALUE ( 'start date'[Date] ) && Data[Date] <= SELECTEDVALUE ( 'end date'[Date] ) ) )
Change the all (data) to ALL (Data[Date] )
Best Regards,
Teige
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |