Forum Discussion
Cumulative Sum by Line
- Anonymous2 years ago
Hi Syndicate_Admin
Please try the following Dax:PreviousMonthOpeningBalance = VAR PreviousMonthBalance = CALCULATE( [WarehouseBalance], FILTER( ALL(Calendar), Calendar[Date] < MIN(Calendar[Date]) ) ) RETURN PreviousMonthBalanceEndingBalance222 = VAR _index = SELECTEDVALUE(Movements[Last Change]) VAR _artical = SELECTEDVALUE(Movements[Item]) VAR PreviousMonthBalance = [PreviousMonthOpeningBalance] VAR Total = CALCULATE( [WarehouseBalance], FILTER( ALL(Movements), Movements[Last Change] <= _index && Movements[Item] = _artical ) ) RETURN IF( _index = MINX(ALL(Movements), Movements[Last Change]), PreviousMonthBalance + Total, Total )
If the above dax can't help you solve your problem, can you provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Syndicate_Admin
Please try the following Dax:
PreviousMonthOpeningBalance =
VAR PreviousMonthBalance =
CALCULATE(
[WarehouseBalance],
FILTER(
ALL(Calendar),
Calendar[Date] < MIN(Calendar[Date])
)
)
RETURN PreviousMonthBalance
EndingBalance222 =
VAR _index = SELECTEDVALUE(Movements[Last Change])
VAR _artical = SELECTEDVALUE(Movements[Item])
VAR PreviousMonthBalance = [PreviousMonthOpeningBalance]
VAR Total =
CALCULATE(
[WarehouseBalance],
FILTER(
ALL(Movements),
Movements[Last Change] <= _index && Movements[Item] = _artical
)
)
RETURN
IF(
_index = MINX(ALL(Movements), Movements[Last Change]),
PreviousMonthBalance + Total,
Total
)
If the above dax can't help you solve your problem, can you provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Good day, thank you very much, if it worked for me. 👍