cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

12 REPLIES 12
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)

Helper I

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

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)

Helper I

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.

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)

Helper I

Hi @NikhilChenna

Continued Contributor

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

Helper I

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 ?

Continued Contributor

Hi @sharong ,

Is this the output you want ?

Regards,

Nikhil Chenna

Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helper I

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

Helper I

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 ),
),
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

Helper I

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.