Forum Discussion

kbabu57's avatar
kbabu57
Regular Visitor
2 years ago
Solved

Cumulative Sum by 2 columns

Hi Folks and Fowmy Jihwan_Kim    I have a requirement where i have to get cumulative sum by 2 columns. The below is the sample data The thing is Final Amount is coming by Customer Number and Year ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi kbabu57 

     

    Ashish_Mathur Good share!

     

    For your question, here is the method I provided:

     

    Here's some dummy data

     

    "Datas"

     

    You can create a measure. Group by customer number, and add up "Diff" and "Balance Pay".

    Final Amount = 
    CALCULATE (
        SUM ('Datas'[Price Amt]),
        FILTER (
            ALLEXCEPT ('Datas', 'Datas'[Customer Number]),
            'Datas'[Year] = MAX ('Datas'[Year])
        )
    )
    + CALCULATE (
        SUM ('Datas'[Diff]),
        FILTER (
            ALLEXCEPT ('Datas', 'Datas'[Customer Number]),
            'Datas'[Year] <= MAX ('Datas'[Year])
        )
    )
    - CALCULATE (
        SUM ('Datas'[Balance Pay]),
        FILTER (
            ALLEXCEPT ('Datas', 'Datas'[Customer Number]),
            'Datas'[Year] <= MAX ('Datas'[Year])
        )
    )
    

     

    Here is the result

     

    Regards,

    Nono Chen

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