Forum Discussion
Power BI doing wrong calculations
- 1 year ago
To ensure the cumulative total is calculated correctly for each month without relying on intermediate or potentially blank values, we can use a SUMX approach. This modified measure iterates over all dates up to and including the current month and adds up the Result values.
Here's the modified measure to accumulate properly:
Cumulative Total = VAR CurrentDate = MAX('Calendar'[Date]) RETURN SUMX( FILTER( ALL('Calendar'), 'Calendar'[Date] <= CurrentDate ), [Result] )- CurrentDate: This variable captures the current row's date in the context, which acts as the endpoint for our cumulative calculation.
- FILTER(ALL('Calendar'), 'Calendar'[Date] <= CurrentDate): This filter retrieves all rows from the Calendar table up to the current date, removing any filters that might interfere.
- SUMX(..., [Result]): By iterating over each date in the filtered range, this formula sums up all [Result] values up to the CurrentDate, ensuring an accurate cumulative calculation.
Best regards,
To ensure the cumulative total is calculated correctly for each month without relying on intermediate or potentially blank values, we can use a SUMX approach. This modified measure iterates over all dates up to and including the current month and adds up the Result values.
Here's the modified measure to accumulate properly:
Cumulative Total =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
SUMX(
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
),
[Result]
)
- CurrentDate: This variable captures the current row's date in the context, which acts as the endpoint for our cumulative calculation.
- FILTER(ALL('Calendar'), 'Calendar'[Date] <= CurrentDate): This filter retrieves all rows from the Calendar table up to the current date, removing any filters that might interfere.
- SUMX(..., [Result]): By iterating over each date in the filtered range, this formula sums up all [Result] values up to the CurrentDate, ensuring an accurate cumulative calculation.
Best regards,
Now it worked, thank you for your help!!! 😄
- cqueiroz22221 year agoHelper I
Hello, DataNinja777 , me again! 😃
Can you please help me to add one more condition (if it would be possible)
when my last month's result be positive (dec/23 =64.228)
next (jan/24 = 138.023) C/C measure must repeat the Result
In excel it would be:
=SE(E20<0;(D21+E20);D21)
E20 = previous month (superior line)
D21 = [Result]