Forum Discussion

Jim_PBI's avatar
Jim_PBI
Frequent Visitor
3 years ago
Solved

Running total using sum with duplicate values in data

I'm trying to calculate a running total using sum which I've already been able to do. The issue is that my data contains duplicates that need to be handled by taking an average/min before I can calcu...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Jim_PBI ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a table.

     

     

    New Table = 
    SUMMARIZE(
    'Table',
    'Table'[Date],
    'Table'[Item],
    "AvgSold", AVERAGE('Table'[Sold])
    )

     

     

    (3)We can create measures.

     

     

    Measure = 
    VAR CurrentDate = MAX('New Table'[Date])
    VAR CurrentItem = MAX('New Table'[Item])
    
    RETURN
    SUMX(
    FILTER(
    ALL('New Table'),
    'New Table'[Date] <= CurrentDate
    && 'New Table'[Item] = CurrentItem
    ),
    'New Table'[AvgSold]
    )
    Running total = SUMX(SUMMARIZE('New Table',[Date],[Item],"total",[Measure]),[total])

     

     

    (4) Then the result is as follows.

     

     

    Best Regards,

    Neeko Tang

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