system.tag.queryTagCalculations - "Minimum" calculation not returning correct value

Hello,

I am trying to query from one of the tags that we are tracking in the historian. We are looking to get the minimum value of the tag from a certain start date up to the current time. We are trying to do so using the queryTagCalculations function, using “Minimum” as the calculation.

However, it seems like the “Minimum” value coming from the function is not correct. Based on the data that I’ve been entering into the tag manually, the minimum value during the time span should be 250. However, the value that this function is returning is 300.

I am also able to confirm that this is not working by running the “Average” calculation as well. When I run that calculation on the same tag over the same time span, the average returned is below 300, which makes sense. But that must mean that at some point the tag had a value of < 300, which means that the “Minimum” being returned in the previous function is not correct.

Is there something we are doing incorrectly here? Please let us know what we need to do.

Input:

ds = system.tag.queryTagCalculations(paths=[equipmentSpeedPath], startDate=equipmentSpliceSignalTime, calculations=["Average"])
for row in range(ds.getRowCount()): 
    print 'Average:', ds.getValueAt(row, 1) 
    
print ''
ds = system.tag.queryTagCalculations(paths=[equipmentSpeedPath], startDate=equipmentSpliceSignalTime, calculations=["Minimum"])
for row in range(ds.getRowCount()): 
    print 'Minimum:', ds.getValueAt(row, 1) 

Output:

Average: 299.003904928

Minimum: 300

Hi,

I’m facing the same problem as you, and queryTagCalculation is not returning the maximum value (ex: I know it’s 900, but it’s returning 100)

I used queryTagHistory and it worked correctly, but until now I don’t understand why and what makes the 2 functions different, since “maximum” should be just one value.

If someone could shed some light on this matter it’ll be much appreciated :slight_smile:

Codes I used below

ret = system.tag.queryTagHistory(paths=tagPath, startDate=start_date, endDate=end_date, returnSize=1, aggregationMode="Maximum", returnFormat='Tall')

ret = system.tag.queryTagCalculations(paths=tagPath, calculations=["Maximum"], startDate=start, endDate=end)