Forum Discussion
Cumulative Difference from Another measure
- 6 months ago
Hi elmurat ,
Thanks for reaching out to Microsoft Fabric Community.
The issue occurs because when multiple rows share the same Battle Date, there is no deterministic row order, which can cause movements to be combined instead of deducted sequentially.
To handle this, I brought NameAccount into the Accounts_Bookings table, sorted the data by NameAccount, Battle Date, and DealName in Power Query, and added a TransactionIndex column to create a stable row order. The running balance then uses this index to ensure row by row subtraction within each account.
Please find the measure below:
Remaining Balance = VAR CurrentAccount = MAX(Accounts_Bookings[NameAccount]) VAR CurrentIndex = MAX(Accounts_Bookings[TransactionIndex]) VAR TotalCash = CALCULATE( SUM(Accounts_Cash[Total Cash]), Accounts_Cash[Account Number] = CurrentAccount ) VAR RunningMovement = CALCULATE( SUM(Accounts_Bookings[Balancito]), FILTER( ALL(Accounts_Bookings), Accounts_Bookings[NameAccount] = CurrentAccount && Accounts_Bookings[TransactionIndex] <= CurrentIndex ) ) RETURN TotalCash - RunningMovementI have attached a screenshot of the output and the PBIX file created using the sample CSV files. Please review and confirm if this aligns with your expected result.
Hi elmurat ,
Just wanted to check if the response provided was helpful. If further assistance is needed, please reach out.
Thank you.
Hi elmurat ,
We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.
Thank you.