Forum Discussion
Calculation with multible variables in time
- 4 years ago
Hi, Anonymous
Based on the data you provide, you can try the following methods.
Current value = SUM(Data[Value])Previous value = Var PrevDate=MAXX(FILTER(ALL('Data'[Date],Data[Year]),'Data'[Date]<SELECTEDVALUE('Data'[Date])&&[Year]=SELECTEDVALUE(Data[Year])),'Data'[Date]) Var Prevalue=CALCULATE([Current value],FILTER(ALL(Data),[Date]=PrevDate)) Return PrevalueOutcome = IF([Previous value]<>BLANK(), [Current value]-[Previous value])The result of the calculation is different from the result you expect. Consider if there is a problem with your desired result calculation?
Let me give you an example.
But in your results.
Please check if there is a problem with your result calculation in Excel, thank you.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Herby simplified data.
Data
| Date | Value | Dimension |
| 1-1-2021 | 100 | LY |
| 1-1-2021 | 100 | LY |
| 1-1-2021 | 125 | LY |
| 1-1-2021 | 100 | LY |
| 30-1-2021 | 125 | LY |
| 30-1-2021 | 125 | LY |
| 30-1-2021 | 150 | LY |
| 30-1-2021 | 125 | LY |
| 28-2-2021 | 200 | LY |
| 28-2-2021 | 200 | LY |
| 28-2-2021 | 200 | LY |
| 28-2-2021 | 200 | LY |
| 30-3-2021 | 300 | LY |
| 30-3-2021 | 300 | LY |
| 30-3-2021 | 300 | LY |
| 30-3-2021 | 300 | LY |
| 30-4-2021 | 500 | LY |
| 30-4-2021 | 500 | LY |
| 30-4-2021 | 500 | LY |
| 30-4-2021 | 500 | LY |
| 30-5-2021 | 600 | LY |
| 30-5-2021 | 600 | LY |
| 30-5-2021 | 600 | LY |
| 30-5-2021 | 600 | LY |
| 30-6-2021 | 1000 | LY |
| 30-6-2021 | 1000 | LY |
| 30-6-2021 | 1000 | LY |
| 30-6-2021 | 1000 | LY |
| 30-7-2021 | 1000 | LY |
| 30-7-2021 | 1000 | LY |
| 30-7-2021 | 1000 | LY |
| 30-7-2021 | 1000 | LY |
| 30-8-2021 | 1300 | LY |
| 30-8-2021 | 1200 | LY |
| 30-8-2021 | 1300 | LY |
| 30-8-2021 | 1400 | LY |
| 30-9-2021 | 1500 | LY |
| 30-9-2021 | 1500 | LY |
| 30-9-2021 | 1500 | LY |
| 30-9-2021 | 1500 | LY |
| 30-10-2021 | 2500 | LY |
| 30-10-2021 | 2500 | LY |
| 30-10-2021 | 3000 | LY |
| 30-10-2021 | 2000 | LY |
| 30-11-2021 | 5000 | LY |
| 30-11-2021 | 5000 | LY |
| 30-11-2021 | 5000 | LY |
| 30-11-2021 | 5000 | LY |
| 30-12-2021 | 6500 | LY |
| 30-12-2021 | 6500 | LY |
| 30-12-2021 | 7000 | LY |
| 30-12-2021 | 6000 | LY |
| 1-1-2022 | 500 | LY |
| 1-1-2022 | 500 | LY |
| 1-1-2022 | 500 | LY |
| 1-1-2022 | 500 | LY |
| 30-1-2022 | 750 | LY |
| 30-1-2022 | 500 | LY |
| 30-1-2022 | 1000 | LY |
| 30-1-2022 | 750 | LY |
| 28-2-2022 | 1000 | LY |
| 28-2-2022 | 1000 | LY |
| 28-2-2022 | 1000 | LY |
| 28-2-2022 | 1000 | LY |
| 30-3-2022 | 2000 | LY |
| 30-3-2022 | 2000 | LY |
| 30-3-2022 | 2000 | LY |
| 30-3-2022 | 2000 | LY |
| 30-4-2022 | 2500 | LY |
| 30-4-2022 | 2500 | LY |
| 30-4-2022 | 2500 | LY |
| 30-4-2022 | 2500 | LY |
| 30-5-2022 | 3000 | LY |
| 30-5-2022 | 3000 | LY |
| 30-5-2022 | 3000 | LY |
| 30-5-2022 | 3000 | LY |
| 30-6-2022 | 6500 | LY |
| 30-6-2022 | 3000 | LY |
| 30-6-2022 | 3000 | LY |
| 30-6-2022 | 3000 | LY |
| 30-7-2022 | 5000 | LY |
| 30-7-2022 | 6500 | LY |
| 30-7-2022 | 3000 | LY |
| 30-7-2022 | 3000 | LY |
| 30-8-2022 | 9000 | LY |
| 30-8-2022 | 6500 | LY |
| 30-8-2022 | 3000 | LY |
| 30-8-2022 | 3000 | LY |
| 30-9-2022 | 10000 | LY |
| 30-9-2022 | 6500 | LY |
| 30-9-2022 | 3000 | LY |
| 30-9-2022 | 3000 | LY |
| 30-10-2022 | 10000 | LY |
| 30-10-2022 | 10000 | LY |
| 30-10-2022 | 3000 | LY |
| 30-10-2022 | 3000 | LY |
| 30-11-2022 | 10000 | LY |
| 30-11-2022 | 10000 | LY |
| 30-11-2022 | 5000 | LY |
| 30-11-2022 | 3000 | LY |
| 30-12-2022 | 10000 | LY |
| 30-12-2022 | 10000 | LY |
| 30-12-2022 | 10000 | LY |
| 30-12-2022 | 10000 | LY |
Outcome needed
| Year | Month | Value |
| 2021 | Januari | 100 |
| 2021 | Februari | 275 |
| 2021 | Maart | 400 |
| 2021 | April | 800 |
| 2021 | Mei | 275 |
| 2021 | Juni | 400 |
| 2021 | Juli | 800 |
| 2021 | Augustus | 400 |
| 2021 | September | 400 |
| 2021 | Oktober | 800 |
| 2021 | November | 400 |
| 2021 | December | 1600 |
| 2022 | Januari | 800 |
| 2022 | Februari | 400 |
| 2022 | Maart | 1600 |
| 2022 | April | 0 |
| 2022 | Mei | 400 |
| 2022 | Juni | 1600 |
| 2022 | Juli | 0 |
| 2022 | Augustus | 1200 |
| 2022 | September | 1600 |
| 2022 | Oktober | 0 |
| 2022 | November | 1200 |
| 2022 | December | 800 |
Hi, Anonymous
Based on the data you provide, you can try the following methods.
Current value = SUM(Data[Value])Previous value =
Var PrevDate=MAXX(FILTER(ALL('Data'[Date],Data[Year]),'Data'[Date]<SELECTEDVALUE('Data'[Date])&&[Year]=SELECTEDVALUE(Data[Year])),'Data'[Date])
Var Prevalue=CALCULATE([Current value],FILTER(ALL(Data),[Date]=PrevDate))
Return
PrevalueOutcome = IF([Previous value]<>BLANK(), [Current value]-[Previous value])
The result of the calculation is different from the result you expect. Consider if there is a problem with your desired result calculation?
Let me give you an example.
But in your results.
Please check if there is a problem with your result calculation in Excel, thank you.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous4 years agoNot applicable
v-zhangti my bad. Indeed my demo data calculation was wrong, my apologies.
This methode does work so thank you.