What's the best way in Ignition Report to get the difference of a tag's value difference between two different time

I did some Ignition report work recently and probably due to my own incompetence this seems like an extremely awkward thing to do.

Basically I had this question when I was trying to do is to get the kwh generated by some power generating assets (solar, disel generator etc.) over some time. There are onsite devices that tracks the kwh, the value is imported with a tag, and all I need to do is to take the difference at 00:00 at {time A} and 00:00 at {time B}.

Now in the reporting module I have set up a {StartTime} and a {EndTime} parameter. From here I have a few choices:

  1. Use tag historian query with the Closest Value Aggregation Mode, get all the data in it's natural logging timestamp, and take a good quality one from near the end and one from near the start, and do the calculation myself with a script.

With this approach, calculating YTD data gets progressively memory and computational heavy as the year go by and the historian query tries to get hundreds of thousands of data points out of the database.

  1. Use the Tag Historian Query with Closes Value Aggregation Mode, sample a fixed size of 2.

This sounds like the way to go but the value it returns is actually one from {StartTime} and another one from {StartTime + (EndTime - StartTime)/2} aka the middle point of {StartTime} and {EndTime}. Now I can just manually set {EndTime} to be twice of what it should be but that just seems silly and gets messy.

  1. Using Tag Calculation Query with the Range calculation.

Now this works for my purpose of calculating the difference of kwh value. But it would fail in other instances where you have a value that's not monotonically increasing or decreasing but you still only need the difference at two specific time.

So I am just curious to see what other people are doing with this kind of calculation in the reporting module.

I don't get why you think option 1 would be memory/resource intensive if it's only pulling 2 values no matter how far apart they are. Ignition doesn't read every value in-between, it only grabs the 2 values you need. And if you're reporting this difference, you don't even need a script as you can use an expression in the report itself to subtract the 2 values.

What you describe would be option 2 for me. And the way to do this is a bit awkward as described in the post. Also how do you actually pull specifics value out of a data source without script? All I get in the Key Browser is this genset_kwh key which is a dataset

Sorry, I guess I misunderstood what you were doing. I'd have to try this, but what if you set up 2 datasources both using the same tag, and one using the starttime for the start and end times for a query to grab 1 value, and the other using the endtime for both the start and end times of that data source. I would hope it grabs just a single value for each, then you can just use those values.

No worries mate. Yeah that does work as you suggested. I just want to know what other ideas people have and what's consider the way to go