Forum Discussion
MarieAmell
3 years agoFrequent Visitor
Running total compare to same date last year
Hi, I have a dataset just as below : ART_Id Date Stock Qty _Stock Last Day Stock <> 0 Nb of days 1 30/04/2020 3000 3000 1 24/06/2020 -5 2995 1 16/09/2020 -1 ...
- 3 years ago
Hi MarieAmell ,
This is my test table:
Please try following DAX to crete new columns:
Stock = CALCULATE ( SUM ( 'Table'[Stock Qty] ), FILTER ( 'Table', 'Table'[Date] <= EARLIER ( 'Table'[Date] ) ) ) Last Day Stock <> 0 = IF ( 'Table'[Stock] = 0, CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( 'Table', 'Table'[Date] < EARLIER ( 'Table'[Date] ) ) ) ) Nb of days = DATEDIFF ( 'Table'[Last Day Stock <> 0], 'Table'[Date], DAY )You will get the table like this:
The result you want:
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MarieAmell
3 years agoFrequent Visitor
Sorry for my very late reply, I was connected with a former account and missed the last messages. Thanks a lot for your help