Duration of switch ON time AWS Timestream

Hello,

I’m having trouble with single stat query. As database i use Amazon Timestream.


As you can see in the picture from db i get time and measure_value::bigint which is state of the pump 1 or 0. I want to have a single stat panel which shows how long pump was working for select period with $__timeFilter when value = 1. In minutes. Could someone help me solve this problem?