Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Cumulative total shown the wrong values.

Hi all, I have written a measure to calculate cumulative total. I didn’t get expected result. My table looks like below image :-   Based on the first column I want to show cumulative tot...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

    You can try adding an Index to the power query or use rank to add a sort.

    Here are the steps you can follow:

    1. In Power query. Add Column – Index Column – From 1.

    2. Create measure.

    total =
    IF(
        [Weighted by view time]=BLANK(),SUMX(FILTER(ALL(table1),'table1'[Index]=MAX('table1'[Index])+1),[Weighted by view time]),
    SUMX(FILTER(ALL(table1),'table1'[Index]<=MAX('table1'[Index])),[Weighted by view time]))
    1 =
    var _table=SUMMARIZE('table1','table1'[112],"_value",[total])
    return
    IF(HASONEVALUE('table1'[112]),[total],SUMX(_table,[_value]))

    3. Result:

     

    Best Regards,

    Liu Yang

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