Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I desperately need to figure this out for my work.
Here's the sample data: https://drive.google.com/file/d/1dI7COyElnNXb33iSk1eiau8ESONHLphf/view?usp=sharing
Here's the overview:
I have a table , named 'Future Date Service Agreement Plans (3)' with two columns that are giving me trouble. They are called:
[Total_Remaining_Cost__c]
and
[Daily_Rate_Based_On_Days_Remaining__c]
Both of these columns repeat the same number over and over again until another dimension in the table [Account Name] changes, then they repeat the process.
Would I would like for them to do is subtract the [Daily_Rate_Based_On_Days_Remaining__c] from the [Total_Remaining_Cost__c] and the have the [Total_Remaining_Cost__c] column go down with each day. So, it would look like this:
But it would need to start over with each [Account ID] change (Which happens when the date in the Day By Day column reaches the date in the EndDate column .
Here's a picture of what the table currently looks like.
Solved! Go to Solution.
I believe you need to do a grouped running total. The only difference is that you need to subtract rather than add. My suggestion is multiply daily rate column with -1 and do a grouped total. It should work. You can search for running total grouped on Google and you will get lot of articles. I just found that this one is useful.
https://www.goodly.co.in/running-total-power-query/
Let me know how this works.
Thanks
Is it correct that the [Days Remaining] column also resets at the Account ID change? If so, you could Group on the Account ID, use the Max aggregation on Days Remaining (let's name that column MaxDay) and an All Rows Aggregation, and then expand the All Rows column. Then, you could do row arithmetic like:
= Table.AddColumn(PriorStepOrTableName, "Amount Left", each [Total Remaining Cost] - (([MaxDays -Days Remaining) * Rate))
--Nate
Thanks, but no luck:
I believe you need to do a grouped running total. The only difference is that you need to subtract rather than add. My suggestion is multiply daily rate column with -1 and do a grouped total. It should work. You can search for running total grouped on Google and you will get lot of articles. I just found that this one is useful.
https://www.goodly.co.in/running-total-power-query/
Let me know how this works.
Thanks
All good, I got it by adding a running total to the daily rate, then using that colum to subtract from the total amount remaining. Thank you
Thanks for that. this is the code that I went with, but it didn't work. Where do I put the minus symbol? Should I not be using the Index column?
= Table.AddColumn(
BufferedTable,
"Running Total",
(OutTable) =>
List.Sum(
Table.SelectRows(
BufferedTable,
(InTable) => InTable[Index] <= OutTable[Index]
and
InTable[Daily_Rate_Based_On_Days_Remaining__c] = OutTable[Daily_Rate_Based_On_Days_Remaining__c])[Total_Remaining_Cost__c]))
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!