Forum Discussion
Anonymous
5 years agoNot applicable
Running count by product
Hi all,
I would like to achieve a running count, reset by product, as such (Count column):
| Product | Count | Date |
| A | 1 | 10/16/2020 |
| A | 2 | 9/25/2020 |
| A | 3 | 10/2/2020 |
| B | 1 | 8/31/2020 |
| B | 2 | 9/24/2020 |
| C | 1 | 9/23/2020 |
| D | 1 | 10/5/2020 |
| D | 2 | 9/7/2020 |
| D | 3 | 10/8/2020 |
| D | 4 | 10/4/2020 |
| D | 5 | 9/9/2020 |
| D | 6 | 9/28/2020 |
It needs to be grouped by product. It also has to be dynamic when filters are applied to the table, so probably a calculated column or measure and not hardcoded. May I know which formula to use?
Thank you.
Anonymous
Try this DAX measure
RunningTotal = VAR _date = SELECTEDVALUE ( 'Table'[Date] ) VAR _product = SELECTEDVALUE ( 'Table'[Product] ) VAR _runningTotal = SUMX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] <= _date && 'Table'[Product] = _product ), 'Table'[Count] ) RETURN _runningTotal
2 Replies
- nandukrishnavsCommunity Champion
Anonymous
Try this DAX measure
RunningTotal = VAR _date = SELECTEDVALUE ( 'Table'[Date] ) VAR _product = SELECTEDVALUE ( 'Table'[Product] ) VAR _runningTotal = SUMX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] <= _date && 'Table'[Product] = _product ), 'Table'[Count] ) RETURN _runningTotal - amitchandakSuper User
Anonymous , Try a measure like
calculate( sum(Table[Count]), filter( Table,[Date] <=Max(Table[Date]) && [Product] =Max(Table[Product])))