Forum Discussion

Salle's avatar
Salle
Advocate I
2 years ago
Solved

Inaccurate Cumulative Sum

Hi, having trouble getting the cumulative sum accurate. Filter issue?   Setup: Two tables: 'Rerun'[RejectCodeID];[Units]  and 'Scrap'[RejectCodeID]; [Units]. One to many: Dimension table 'RejectC...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Salle ,

     

    I'm suspecting you're trying to accumulate based on total largest to smallest, and you can check the results as follows:

    Rank = 
    VAR _1=RANKX('Table (2)','Table (2)'[Total],,DESC,Dense) 
    
    VAR _2 =
    RANKX('Table (2)','Table (2)'[RejectCodeID],,ASC,Dense)/ POWER(10,ROUNDDOWN(COUNT('Table (2)'[RejectCodeID])/10,0)+1)
    RETURN
    _1 + _2
    
    Cumulative Rejects = 
    VAR TotalRejects = [Re] + [Sc]
    Return
    CALCULATE(
        SUM('Table (2)'[Total]),
        FILTER(
            ALLSELECTED('Table (2)'),
            'Table (2)'[Rank] <= MAX('Table (2)'[Rank])
        )
    )

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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