I created the following queries to show me the difference between yesterday and today. However, the result keeps changing between a positive and negative value. The value itself remains the same, only the sign changes. I suspect that the order in union is not fixed and that is where this comes from, but I could be wrong. Does anyone have an idea how to fix the problem?

The value can be negative, so math.abs unfortunately does not fix the problem.

I use the query in Grafana, so I took the approach of using the selected period for today and the same period minus 1 day for yesterday, so I compare the latest values in each of these periods.

Update: One more thing I noticed is that the value also changes between negative and positive when it does not change, so no new values are added.

I implemented it this way, but the result is NaN. Even though I don’t know why you have today and yesterday in the screenshot, I only have Value 1 and Value 2, the two values (unsigned integer) are correct in the output.

In order for the Binary Operation transformation to work, you will need to make Value 1 and Value 2 numbers using separate transformations BEFORE the binary transformation. Something like this:

If I do a conversion transformation before the binary operation transformation, then I can’t select the fields, but I noticed that when I switch to table view, I logically have two timestamps, each with Value 1 and Value 2 and two empty entries. Maybe it tries to calculate with the empty values?

I have found a solution. If I apply the transformation concatenate fields before, both values are written in one row, so the calculation works now. I don’t know if it is the best solution, but it is one that works as of now.