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 all,
I am facing a problem in my Power BI File.
I am making a calculation based on some variable. What I am doing is comparing two numbers (current and past period) with each other to calculate the difference. To counter very small values there is a IF statement to filter these small values. My current Dimensionula is:
VAR LY_This_Period = CALCULATE(SUM('Table1'[Amount]),'Table1'[Dimension]=“Dimension”)
VAR LY_Past_Period = CALCULATE(SUM('Table1'[Amount]),PARALLELPERIOD('Calendar'[Date],-1,MONTH),'Table1'[Dimension]=“Dimension”)
VAR LY_Production_Period_DuringYear = CALCULATE(SUM('Table1'[Amount]),'Table1'[Dimension]=“Dimension”)-CALCULATE(SUM('Table1'[Amount]),PARALLELPERIOD('Calendar'[Date],-1,MONTH),'Table1'[Dimension]=“Dimension”)
RETURN
IF(AND(LY_Production_Period_DuringYear<0.049,LY_Production_Period_DuringYear>-0.049),BLANK(),
IF(OR(LY_Past_Period=0,LY_This_Period=0),BLANK(),LY_Production_Period_DuringYear))
But the problem that I face is that in the month Januari it should not take the parral period but the first date of the year. Consequential it is needed that in February the calculation only is made based on the last date of January instead of the total calculation of January.
Do you have any tips or suggestions?
Solved! Go to Solution.
Hi, @Endurion
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
Prevalue
Outcome = 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.
@v-zhangti @lbendlin , sorry for my late responce I was on holiday.
This is the problem. Hope it helpst, otherwise please let me know.
Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
You may use the data of the picture. This is a simplified sample. I can not share other data due to the GDPR.
Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
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, @Endurion
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
Prevalue
Outcome = 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.
@v-zhangti my bad. Indeed my demo data calculation was wrong, my apologies.
This methode does work so thank you.
Conditional Delta :=
var a = max(Data[Date])
var b = CALCULATE(max(Data[Date]),All(Data),Data[Date]<a)
var c = CALCULATE(sum(Data[Value]),all(Data),Data[Date]=b)
var d = CALCULATE(sum(Data[Value]),all(Data),Data[Date]=a)
return d-c
see attached. You can modify as needed to cater for the dimension filters etc.
Hi, @Endurion
Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures.
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.
Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
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 |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |