Forum Discussion
Jim_PBI
3 years agoFrequent Visitor
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...
- Anonymous2 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.
Anonymous
2 years agoNot applicable
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.