Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

DAX Measure (Dynamic Cumulative Sum)

I want to create the cumulative total based on the rank (in this case a Measure Count), unfortunately I can't get it to work with this attempt. I always get the total and not the running total.
Do you have any idea how to do it?

Lines_Cum = 

VAR CURRENTRANK = [COUNT]

RETURN

SUMX(

    FILTER(

        ALL(FAKTWA_DAT),

        Currentrank <= MAXX(FaktWA_DAT,[Count])

        ),

        [LINES]

)
COUNT = RANKX(ALL(FaktWA_DAT),[AS_Index],,ASC,DENSE)-1

 

 


 

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Try:

    Lines_Cum = 
    
    VAR CURRENTRANK = [COUNT]
    
    RETURN
    
    SUMX(
    
        FILTER(
    
            ALL(FAKTWA_DAT),
    
            [Count] <= Currentrank 
    
            ),
    
            [LINES]
    
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      unfortunately it didn't work, I found another solution. (Index made in PQ and then SUMX with AS_LINES (dynamic Lines) but it only works for counts smaller than 1000. After that, the working memory has problems and displays an error message. 

      Lines_Cum = 

      SUMX(

             

          FILTER(

              ALL(FAKTWA_DAT),

              FaktWA_DAT[Index] <= MAX(FaktWA_DAT[Index])

              )

          ,[AS_Lines]

      )