Forum Discussion
Running total measure
I'm using the following measure and it's great. The solution was posted in the topic below:
Solved: Re: Running Total solution for slicer - Microsoft Power BI Community
<<<RunningTotal = var thisdate = CALCULATE(MAX(Total[Date]), ALLSELECTED(Total[Account]))
It's providing Running totals for the Accounts for the selected dates range. But, it's cutting off all accounts that could have balances/running totals if they don't have any sales for the selected dates.
So, I'm facing the situation when I'd need to have all those accounts with balances even if they do not have any sales in the selection range "From ... To ...."
That would be 0 for the Amount with some number for Running Total that came from all previouse/before the selected dates range periods.
Could this measure be modified to do it?
2 Replies
- AnonymousNot applicable
Hi Tom2001 ,
I'm not clear about your requirement. Would you like to get the balances/running totals even though there is no sales? Could you please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community.
How to upload PBI in Community
Best Regards
- Tom2001Regular Visitor
HI yingyinr,
Thank you for your reply. Here is a simple table that could explain it.Accounts Date Sales Running Totals Account1 1/1/2022 100 100 Account2 1/2/2022 200 200 Account1 1/3/2022 50 150 Account5 1/4/2022 1000 1000 Account2 1/5/2022 2000 2200 Account3 1/6/2022 1000 1000 Account2 1/7/2022 1000 3200 Report From 1/4/2022 To 1/7/2022 Account Dates Sale Running Total Account1 0 250 Account2 3000 3200 1/5/2022 2000 2200 1/7/2022 1000 3200 Account3 1000 1000 1/6/2022 1000 1000 Account5 1000 1000 1/4/2022 1000 1000 The Account1 is missing from the report as there was no Sales for the selected dates "From ... To ..." but there is Running Totals/Balance that should be shown.
If it's even all 0 it would need to be shown if the account exists.
In the old SQL of course it could be left outer and that would be it But, here I hope I could avoide accounts and all dates cross join and merging all together with the data table. For the paginated report it seems as it's good to have just a one flat table as a source.
Thanks in advance