cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sharong
Helper I
Helper I

Running Total for non date column

I am trying to do running total on non date column. I am trying to show it in a table visual. I have 18k rows.
Following the below dax, its working for me if i limit rows to first 1000 rows. But for entire data, its keeps loading and not coming up.
Can you help me in optimizing the dax measure or is there any other way to achieve this.

 

My table visual would have the following columns:
CUSTOMER_NO, CUSTOMER_NAME, CODE, COUNTRY, UNIT, Rank, Total receivables, Running total

 

The following is the measure I have used:
Product Running Total =

var pdtrank = RANKX(ALLSELECTED(table[CUSTOMER_NO], table[CUSTOMER_NAME], table[CODE], table[COUNTRY], table[UNIT]), [totalReceivables], , DESC, Dense)

var runningtotal =
CALCULATE([totalReceivables],
FILTER(ALL(table[CUSTOMER_NO], table[CUSTOMER_NAME], table[CODE], table[COUNTRY], table[UNIT]),
pdtrank >= RANKX(ALLSELECTED(table[CUSTOMER_NO], table[CUSTOMER_NAME], table[CODE], table[COUNTRY], table[UNIT]), [totalReceivables], , DESC, Dense)
) )
return

IF(
[totalReceivables] <> BLANK(),
RunningTotal
)

 

Below is the error I m getting

If I dont limit the data to first 1000 rows, then its keeps loading and never gives the result

sharong_0-1669708296385.png

 

12 REPLIES 12
NikhilChenna
Continued Contributor
Continued Contributor

Hi @sharong ,

 

I think the issue is loading the measure. The measure seems bit complex. 

I suggest you to use SUMX and minimize the formula.

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

Hi,
Can you provide me the minimized formula using sumx . will try it out

NikhilChenna
Continued Contributor
Continued Contributor

Hi @sharong ,

 

Can you only share you sample table as well as a expected output table for it. so that it will be easy for me to test it out too.

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

This is the existing table i have. I want a new column "Running sum" of receivables based on rank st. 
Total number of rows in dataset is 18079 rows.

sharong_1-1669729800727.png

 

NikhilChenna
Continued Contributor
Continued Contributor

Hi @sharong ,

 

Create the below measure ,

 

 

Running total sales =

VAR IndexRank = [Rank ST]

 

RETURN

    CALCULATE (

        SUM ( 'table1'[Receivables]),

        FILTER (

            ALL ( 'table1'[customer_no] ),

            IndexRank

                >= RANKX ( ALLSELECTED ( 'table1'[customer_no] ), [sum],, ASC, DENSE )

        )

    )

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

 

Hi @NikhilChenna 
This too is not working. The table visual keeps loading. Can you please help me out. 18k rows is a small dataset. Dont know why it keeps loading. Please help me out. Struck with this for last 1 week

sharong_0-1669737190924.png

 

NikhilChenna
Continued Contributor
Continued Contributor

Hi @sharong , Is it possible can you share you pbix file. 

 

 

@amitchandak can you please help me in this. I am not getting a proper reply from anyone

https://drive.google.com/file/d/1IRw6GIiZyFeCXMb3-ARe_WQh86Yva7zf/view?usp=sharing 

 

If I drag the running sum measure into the table visual, it keeps loading and not coming up for 18k rows. But for less rows like first 1000 rows, its working. Can you please provide me with a solution on urgent basis ? 

NikhilChenna
Continued Contributor
Continued Contributor

Hi @sharong ,

 

Is this the output you want ?

 

NikhilChenna_0-1669798723564.png

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

hi @NikhilChenna 7is there any update on this issue?

Hi @NikhilChenna 

I tried using the below codes. It takes some 4-5 minutes to load the table. Is there any way of optimizing the below code. Can you help me out.

 
TestRank = IF(ISBLANK([Total Receivables]), BLANK(),
RANKX (
    SUMMARIZE (
        ALLSELECTED ( Table ),
        Table[CUSTOMER_NO],  Table[CUSTOMER_NAME], Table[COMPANY_CODE], Table[COUNTRY], Table[BUSINESS_UNIT]   
    ),
    CALCULATE ( SUM ( Table[Total Receivables] ) ),
    ,
    DESC,
    DENSE
))

-----------------------------
Test Running Total =
       VAR CurrentRank = [TestRank]
    VAR Summarizetable =
        CALCULATETABLE (
            SUMMARIZE ( Table, Table[CUSTOMER_NO], Table[CUSTOMER_NAME], Table[COMPANY_CODE],Table[BUSINESS_UNIT],Table[COUNTRY] ),
            ALLSELECTED ( Table )
        )
    VAR small =
        ADDCOLUMNS ( Summarizetable, "@Sales", [Total Receivables], "@Rank", [TestRank] )
    VAR Result =
        SUMX ( FILTER ( small, [@Rank] <= CurrentRank ), [@Sales] )
    RETURN
        Result




Yeah but why every value in running sum column is same. I want a cumulative sum 

Helpful resources

Announcements
Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.