Forum Discussion

bryanrendra's avatar
bryanrendra
Icon for Helper II rankHelper II
6 years ago
Solved

Cumulative total with multiple item and time

 I have been googling and still cant find the best way to generate updated price value. I am trying to find updated price value that coming from original price + running total incremental price in gi...
  • amitchandak's avatar
    6 years ago

    bryanrendra , Try one of the two

     

    DropPrice = 'Table'[Original Price]+CALCULATE(SUM('table'[IncrementalPrice]),
    filter(
    ALLSELECTED('table'),'table'[Date]<= max('table'[Date]) && 'table'[item] max(='table'[Date])))



    DropPrice = 'Table'[Original Price]+CALCULATE(SUM('table'[IncrementalPrice]),
    filter(
    ALLSELECTED('table'),'table'[Date]<= max('table'[Date]) ))

  • Anonymous's avatar
    Anonymous
    6 years ago

    I have copied your sample data as a new table named "Pricing" 

     

    Table Name : Pricing

     

    ItemOriginal PriceDateIncremental Price
    Pencil301-Jan-19 
    Pencil302-Jan-190.8
    Pencil303-Jan-19 
    Pencil304-Jan-190.2
    Pencil305-Jan-190.3
    Pencil306-Jan-19 
    Book501-Jan-191
    Book502-Jan-19 
    Book503-Jan-19 
    Book504-Jan-193
    Book505-Jan-19 

     

    Added the following Calculated Column

     

     

    Updated Price =
    VAR OriginalPrice = Pricing[Original Price]
    VAR CurrentItem = Pricing[Item]
    VAR CurrentDate = Pricing[Date]
    VAR CumulativePriceChanges =
        SUMX (
            FILTER (
                ALLSELECTED ( Pricing ),
                Pricing[Item] = CurrentItem
                    && Pricing[Date] <= CurrentDate
            ),
            Pricing[Incremental Price]
        )
    VAR UpdatedPrice = OriginalPrice + CumulativePriceChanges
    RETURN
        UpdatedPrice

     

    This gave me the following Result.

     

    ItemOriginal PriceDateIncremental PriceUpdated Price
    Pencil301-Jan-19 3
    Pencil302-Jan-190.83.8
    Pencil303-Jan-19 3.8
    Pencil304-Jan-190.24
    Pencil305-Jan-190.34.3
    Pencil306-Jan-19 4.3
    Book501-Jan-1916
    Book502-Jan-19 6
    Book503-Jan-19 6
    Book504-Jan-1939
    Book505-Jan-19 9