Math expression on two queries with different update intervals

Hello.
I’m trying to implement math equatin to my dashboard. I want to get difference of query B and A, problem is that, those queries have different update intervals (one is updated once per 10 seonds and second once per 5 minutes). Simple equation $B - $A runs to blank gauge.


How to skip timestamps and consider only latest value?