How to perform calculations in a column of a table?

image,

How can I make the difference of the field (Maximum) - (Minimum) and put it in the Total field.
It is to be able to calculate the Energy per hour from a historical data obtained from an electric energy meter

Welcome to the forum, Armando.
Can you edit (pencil icon) and add an English translation - even https://translate.google.com - to the title and the post?

ok

I think you are asking how to calculate the difference between Maximo and Minimum. You should do this in your SQL query.

SELECT
    t_tstamp,
    Maximo,
    Minimo,
    (Maximo - Minimum) AS Total
FROM
    ....

The data in the table is from this Tag History query, where should your code go?

Add the tag with the Range aggregation mode.

image

From the same TAg I have the Maximum and the minimum value every 5 minutes, and I need to subtract those values

Using Historian will not work well. You will miss some data.

Maximo not the same

You need these numbers to be the same. Historian does not work the way you think it does.

You could ignore the minimum and use a script to calculate
diff = Maximon - Maximon-1

1 Like

Sorry, but I'm new to this, and I don't know where I should enter the Script, I will have to get the data from the TAg History where the energy meter is being stored, RIGHT?

Below your Tag History Binding there should be an Add Transform button. Hit that and select Script.

Someone else will have to help you with the script as I don't have a test database at the moment.