Forum Discussion

EnrichedUser's avatar
EnrichedUser
Icon for Helper III rankHelper III
5 years ago

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

  • 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.

     

    • EnrichedUser's avatar
      EnrichedUser
      Icon for Helper III rankHelper III

      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's avatar
    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.

    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.

    • EnrichedUser's avatar
      EnrichedUser
      Icon for Helper III rankHelper III

      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. 





  • yenkk's avatar
    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?