Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
EnrichedUser
Helper III
Helper III

Running Total Non Date - Not Enough Memory

Good Day,

 

I am trying to calculate the running total of open orders. The table of concern is SalesOrders.

 

It has nearly 1 million rows while open rows only make up less than 10k.

 

I have not been able to validate if any of my attempts have worked since I keep running out of memory, which means I am completely inefficient even if one of my tests do "work". I need a new messure that is efficient to calculate the running total of open orders.

 

Data Sample:

BranchID    CustomerID    SalesOrderID     Line Number   Status   Total Price
A111S1001Open100
A111S1002Open200
B111S1021Open300
B222S1031Closed400
C222S1041Open500
C333S1051Closed600


Expected Outcome:

SalesOrderIDTotalPriceRunning Total
S104500500
S102350850
S1003001150

 

Notes/Messures:
It is possible for some SalesOrderID to appear more than once. 

The visual will need to be dynamic to the different filters on BranchID, CustomerID so I have had been using ALLSELECTED.

Ive tried using a sumarize/summarizecolumn functions to display a table with only open status.

 

Open Dollars =
CALCULATE(SUM(SalesOrders[TotalPrice]), SalesOrders[Status] = "Open")

Cumulative Open Sales Test 1 =
VAR IndexRank = 'Ranking Index'[Ranking Index Value]

RETURN
SUMX(
FILTER(
SUMMARIZE(SalesOrders, SalesOrders[SalesOrderID],
"Sales", [Open Dollars],
"Sales Ranking", RANKX(ALLSELECTED( SalesOrders), [Open Dollars],, DESC)),
[Sales Ranking] <= IndexRank),
[Sales] )

Cumulative Open Sales Test 2=
VAR RANKING =
RANKX(VALUES(SalesOrders[SalesOrderID]), [Open Dollars],,DESC,Dense)
VAR RunningTotal =
CALCULATE([Open Dollars], SalesOrders[Status] = "Open",
FILTER(VALUES(SalesOrders[SalesOrderID]),
RANKING >= RANKX(
VALUES(SalesOrders[SalesOrderID]),
[Open Dollars],,
DESC,Dense)
)
)

RETURN
RunningTotal
10 REPLIES 10
yenkk
Regular Visitor

avez vous trouvez la reponse a votre besoin je suis dans la mçeme situation que vous. je fais un total cumulée mais j'ai trop de lignes dans la table?

Anonymous
Not applicable

Hi  @EnrichedUser ,

Here are the steps you can follow:

1. Create calculated table.

index =
RANKX('Table',[SalesOrderID],,DESC,Dense)

2. Create measure.

Total_Price_Measure =
CALCULATE(SUM('Table'[Total Price]),FILTER(ALL('Table'),'Table'[SalesOrderID]=MAX('Table'[SalesOrderID])&&'Table'[Status]="Open"))
Running Total =
 var _1=SUMX(FILTER(ALLSELECTED('Table'),'Table'[index]<=MAX('Table'[index])&&'Table'[Status]="Open"),[Total Price])
 return
 IF(MAX('Table'[Status])="Closed",BLANK(),_1)

3. Place [Total_Price_Measure] and [Running Total] in Viual, and click the SalesOrdelID column to sort by

4. Result.

v-yangliu-msft_0-1614586559493.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous 

thank you for your time. I was able to test and modify these messures and did not run into the some memory issues as before. However, there was some problem for the running total calculating correctly. 
From what I could see, the duplicated SalesOrderIDs would not correctly summarize. 

Cumulative Total Open Dollars =
var Dollars = [Open Dollars]
return
SUMX(
FILTER(
SUMMARIZE(ALLSELECTED(SalesOrders), SalesOrders[SalesOrderID],
"@dollars", [Open Dollars]),
[@dollars] >= Dollars ),
[@dollars] )
 
This is my current messure, but the processing time is still very slow at around 4 minutes. 





Ashish_Mathur
Super User
Super User

Hi,

These are the measures i wrote

Price = SUM(Data[Total Price])
Rank by price of Sales order = if(HASONEVALUE(Data[SalesOrderID]),RANKX(ALL(Data[SalesOrderID]),[Price]),BLANK())
Cumulative price = SUMX(TOPN([Rank by price of Sales order],CALCULATETABLE(VALUES(Data[SalesOrderID]),ALL(Data[SalesOrderID])),[Price],DESC),[Price])

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

HI @Ashish_Mathur 

 

Thank you for your time and quick reply. I spent a while this today working through this one. Sadly, I was not able to use as it still took too long to run. 

I think the primary issue is that, I am only considering about 10k rows that are open and need to filter out the other 1m. 

Anonymous
Not applicable

Hi @EnrichedUser  ,


The total is incorrect because my sample data S102 is 300 when it is Open, not 350Change the sample data and enter the above formula. The result is:

v-yangliu-msft_0-1614732196363.jpeg

You can use our formula to compare the loading time


The loading time is too long. You can optimize the Dax function to reduce useless data and clear the Dax cache. For details, you can check these links:

https://maqsoftware.com/expertise/powerbi/dax-best-practices

https://powerpivotpro.com/2019/03/dax-optimizations-write-it-like-the-dax-calls-it/

 

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous, Thank you again and you are right. It looks like I misstyped 350 for 300. 

I have tried this method again and am looking into further optimizing my reports. Unfortunately, I am still not able to quickly populate the Running Total Messure and even the Total_Price_Messure takes a great deal of time. The issue may be somewhere else in my file, but these are the only portions of my entire report that has a processing problem with all other messures under 500 ms and the top across all reports less than 1400 ms. 

Anonymous
Not applicable

Hi  @EnrichedUser  ,

The speed on power bi Desktop is slow, and the solution seems to be only dax optimization and reduction of useless data. You can also put the data into the SQL server and use Direct Query to input data, which will be faster

You can use DAX Studio to optimize the inspection of DAX statements from a performance perspective and use the Performance analyzer to check the performance of each of your report elements when users interact with them, and which aspects of performance consume the most (or least) resources


This is a link to related content, I hope it will help you:

https://daxstudio.org/

https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-performance-analyzer

 

Best Regards,

Liu Yang

I will look into the dax studio. 

My guess is going to be that I have to optimize the code for the running total which is what I am looking for: an optimized running total dax solution. 

Anonymous
Not applicable

Hi  @EnrichedUser  ,

This is the introduction, installation and use of Dax studio. I hope it will help you:

https://powerbi.tips/2020/05/introduction-to-dax-studio/

https://exceleratorbi.com.au/getting-started-dax-studio/

https://www.sqlbi.com/articles/capturing-power-bi-queries-using-dax-studio/

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors