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 two measures I created to calculate the difference of Saldo between months.
First one is calculating the saldo of end of month:
SaldoEOM =
VAR Latest_Date = MAX('Table1'[Date])
RETURN
CALCULATE (SUM('Table1'[Saldo]), 'Table1'[Date] = Latest_Date)
Second one is getting the saldo of end of month from previous month:
SaldoEPM =
CALCULATE(SUM('Table1'[Saldo]),
'Table1'[Date] = EOMONTH(max('Table1'[Date]),-1),
ALLEXCEPT('Table1', 'Table1'[Saldo], 'Table1'[Date], 'Table2'[System], 'Table3'[variable1],'Table4'[variable1]))
Third one is calculating the difference between them:
SaldoChange = [SaldoEOM] - [SaldoEPM]
The result looks like this:
Year | Month | SaldoEPM | SaldoEOM | SaldoChange | System |
2023 | Jan | 0 | 10 | 10 | A |
2023 | Feb | 10 | 20 | 10 | A |
2023 | Mar | 20 | 12 | -8 | A |
2023 | Apr | 12 | 15 | 3 | A |
2023 | May | 15 | 20 | 5 | A |
2023 | Jun | 20 | 50 | 30 | A |
2023 | Jan | 0 | 65 | 65 | O |
2023 | Feb | 65 | 42 | -23 | O |
2023 | Mar | 42 | 95 | 53 | O |
2023 | Apr | 95 | 56 | -39 | O |
2023 | May | 56 | 52 | -4 | O |
2023 | Jun | 50 | 50 | O |
The problem is the SaldoEPM in the last line (Jun) for system "O" is not getting the value 52, as it should (like for system "A" 20).
I appreciate the help!
Hi,
Try this approach
Total = sum('Table1'[Saldo])
Total in pm = calculate([total],previousmonth(calendar[date]))
Variance = [Total in pm]-[Total]
Hope this helps.
Hi @Ashish_Mathur
Thank you for your reply. Unfortunately I cannot create Calendar table as I am working with PowerBI datasets and I do not have the rights to create them.
In any case, I appreciate your input, but if you have any other suggestions, that will be awesome as well.
Thank you,
Pamela.
Hi @pamsardinha
1. Please check if there is data for the date column 5/31 in the "o" type in your table, the current return is empty may have no data for the date column 5/31 last month, or there is no number 5/31 in the date column.
2.You can try the following measure
SaldoEPM =
CALCULATE (
SUM ( 'Table1'[Saldo] ),
FILTER (
ALLSELECTED ( 'Table1' ),
'Table1'[Date] = EOMONTH ( MAX ( 'Table1'[Date] ), -1 )
&& [System] IN VALUES ( 'Table2'[System] )
)
)
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your reply.
I tried with your measure and it returns the same error...
I am sure that there is value at end of 31/5 because I can see in the calculate column SaldoEOM (in my example is 52 for system O).
If you have any other suggestion, I appreciate.
Thank you,
Pamela.
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 |
---|---|
96 | |
95 | |
82 | |
71 | |
64 |
User | Count |
---|---|
115 | |
105 | |
95 | |
79 | |
72 |