Query sum max until zero

Hi everybody,

I’m trying to make a table where i can find the total consumption of a machine in relation to an ID number. If the machine never shuts down i can see what is the maximum value of the component it and show the correct value. The problem is when the value goes back to zero and restart a new count

As you can see here, the machine stop three times and restart the count. In the transformation, if i just take the “max” it will only show 31,1 (as you can see in the image below) but the correct value i want is “40.65”

I use this transformation to represent the table grouped by “ID NUMBER”

Can you guys help me with this? It’s even possible watch the max to zero and sum all this values regarding with “ID Number”?

The query that i’m use right now is: