Forum Discussion

PradipMCT's avatar
PradipMCT
Resolver II
8 years ago
Solved

Running total

Hello friends,   I am trying to calculate a running total based on orders table.    I get wierd result. please check and help. i would like to get the running total based on category wise sales. ...
  • Vvelarde's avatar
    8 years ago

    PradipMCT

     

    Hi, try with this:

     

     

    Total sales running =
    VAR TOT =
        CALCULATE ( SUM ( Orders[Sales] ) )
    RETURN
        CALCULATE (
            [Total sales],
            FILTER ( ALLSELECTED ( 'Products2'[Sub category] ), [Total sales] <= TOT )
        )

     

    Regards

     

    Victor

    Lima  Peru

  • PradipMCT's avatar
    PradipMCT
    8 years ago

    Hi Victor,

     

    Thanks for the solution. It did work. Thanks again for that. just a simple question,

     

    I am trying to understand that function when removed the variable syntax and tried to do without it doesnt work, could you kindly explain? and why do we have to write calculate twice?

  • Vvelarde's avatar
    Vvelarde
    8 years ago

    PradipMCT

     

    The Var made a Calculate of Total Sales in this context. (Current Subcategory)

     

    So The Filter Search all The  Subcategories with "Total-Sales"  Lower than the Total Sales of Actual Subcategory.

     

    If you put directly in the filter its saying total Sales (Measure) are equal to Sum of Total Sales .

     

     

  • PradipMCT's avatar
    PradipMCT
    8 years ago

    Thanks Victor, 

     

    That helps.