Forum Discussion
Cumulative Line Chart for Mileage Register
Hi,
I have a huge 'timesheet' like dataset where every employee registers the car they used and how many miles they made:
It generates a nice line chart where I can see mileage changes:
but my goal is to have the total mileage at the end, so I would like to have something like:
January 2022 - 0 miles,
February 2022 - 1250 miles,
March 2022 - 5000 miles,
April 2022 - 6000 miles, etc.
instead of
January - 0 miles,
February - 1250 miles,
March - 3750 miles,
April - 1000 miles, etc.
Could you please help me with that? Thank you!
pal95 , Using a date table in measure and visual axis
Cumm = CALCULATE(SUM(Table[Miles]),filter(all('Date'),'Date'[date] <=max('Date'[date])))
or
Cumm = CALCULATE(SUM(Table[Miles]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))
9 Replies
- pal95
Helper III
Hi, just created a sample for you:
Date Registration Miles 1/17/2022 A 21 1/11/2022 A 3 1/12/2022 A 71 1/17/2022 A 82 1/5/2022 B 85 1/6/2022 A 87 1/17/2022 B 23 1/8/2022 B 44 1/9/2022 B 47 1/4/2022 B 54 1/11/2022 C 16 1/12/2022 C 54 1/17/2022 C 96 1/4/2022 A 29 1/15/2022 C 99 1/16/2022 B 13 1/17/2022 B 22 1/4/2022 C 52 2/19/2022 C 24 1/20/2022 B 23 1/21/2022 A 93 2/17/2022 C 59 1/23/2022 C 56 1/24/2022 A 80 1/25/2022 C 50 Best regards,
- amitchandak
Super User
pal95 , Using a date table in measure and visual axis
Cumm = CALCULATE(SUM(Table[Miles]),filter(all('Date'),'Date'[date] <=max('Date'[date])))
or
Cumm = CALCULATE(SUM(Table[Miles]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))
- pal95
Helper III
Hi, it doesn't work - the output looks the same as the original. I tried both. Also, I can't just put allselected('Date'), I have to add a table name before, does it matter?
- keshavagrawal27
Resolver I
Hello pal95,
It can be acheived by using Bar Chart.
If this helps you then please mark it as a solution and hit the thumbs up. Thanks.
- pal95
Helper III
I need a line chart to then compare it with other data
- Arul
Super User
- Arul
Super User
pal95 ,
First create running total and then use the below formula to calculate above numbers,
Runningtotal = CALCULATE ( SUM ( Sample_Table[Miles] ), FILTER ( ALL ( 'Sample_Table' ), Sample_Table[Date] <= MAX ( Sample_Table[Date] ) ) )Totalcalculation = VAR _sumofa = SUM ( Sample_Table[Miles] ) RETURN _sumofa - [Runningtotal]Let me know if it works or not.
Thanks,
Arul
- pal95
Helper III
It kind of works but seems to be going the opposite way, to negative numbers