I would like to take the data in that dataset and create another dataset with the daily flow total from each day, which is achieved by subtracting the previous days running total. Example:
I have talked to tech support and they have recommended scripting to create the dataset I am looking for, but I am not very good at creating new scripts. I can understand and modify an existing script, but do not have the skill level to create one. If someone could point me in the right direction or offer any type of assistance I would appreciate it.
Tech support also recommended scripting in MySQL, but I would like to keep this data in Ignition if I could. Thanks.
SELECT t.t_stamp,
t.Totalizer1,
COALESCE((t.Totalizer1- (SELECT t1.Totalizer1
FROM MyTable as t1
WHERE t1.t_stamp = DATEADD(day, -1, t.t_stamp))),0) as Total
FROM MyTable as t
EDIT: I changed the AttrValue to Totalizer. Sorry about that.
I added the COALESCE to return ‘0’ if null, you can remove it if you want.
Then I just take today’s value - yesterdays and call it Total.
[quote=“CPowell”]Doing it in SQL is the easiest solution.
SELECT t.t_stamp,
t.Totalizer1,
COALESCE((t.AttrValue - (SELECT t1.AttrValue
FROM MyTable as t1
WHERE t1.t_stamp = DATEADD(day, -1, t.t_stamp))),0) as Total
FROM MyTable as t
I added the COALESCE to return ‘0’ if null, you can remove it if you want.
Then I just take today’s value - yesterdays and call it Total.
Hope that helps!
Cheers,
Chris[/quote]
This will take me a little while to wrap my head around (doesn’t help that I am coming down with a cold…). I will mess around with it in a test database. Our dataset is comprised of 159 columns, so I will have to make it work with all of them. Thanks for the assistance!