[IGN-15587]Historian Query Aggregated Points for Multiple Tags and Aggregates

Ignition Version: 8.3.3

I am attempting to use system.historian.queryAggregatedPoints for multiple tag paths and return multiple aggregates for each tag.

Below is how I would expect the proper syntax to be formatted, but I receive the error “The paths and aggregates lists must be the same size”. I have attempted to have the tag_list and aggregate_list to be one-to-one, but I have yet to get the expected output.

Any suggestions are appreciated!

Example Syntax:

tag_list = ['[TEST]Tag_1', '[TEST]Tag_2']
aggregate_list = ['Minimum', 'Maximum', 'Average']
end_time = system.date.now()
start_time = system.date.addDays(end_time, (-30))

query = system.historian.queryAggregatedPoints(
        paths = tag_list,
        startTime = start_time,
        endTime = end_time,
        aggregates = aggregate_list,
        returnFormat = 'CALCULATION'
)

From a quick peek at the internals of the function, I think you have to do something like this:

tags = ['[TEST]Tag_1', '[TEST]Tag_2']
aggregates = ['Minimum', 'Maximum', 'Average']
end_time = system.date.now()
start_time = system.date.addDays(end_time, (-30))

tag_list = [
	tag 
	for tag in tags
	for _ in aggregates
]
aggregate_list = aggregates * len(tags)

query = system.historian.queryAggregatedPoints(
	paths = tag_list,
	startTime = start_time,
	endTime = end_time,
	aggregates = aggregate_list,
	returnFormat = 'CALCULATION'
)

Where the two input lists become this:

['[TEST]Tag_1',   ['Minimum',
 '[TEST]Tag_1',   'Maximum',
 '[TEST]Tag_1',   'Average',
 '[TEST]Tag_2',   'Minimum',
 '[TEST]Tag_2',   'Maximum',
 '[TEST]Tag_2']   'Average']

You might want/need to add column name aliases, which you could generate with another comprehension:

name_list = [
	"%s.%s" % (tag, aggregate)
	for tag in tags
	for aggregate in aggregates
]

Hey Paul,

I have attempted to provide input lists as outlined, but I am encountering two issues.

  1. The list now returns a functions with (2+ (n*m)) rows. For example, if I input 2 tags and 3 aggregates it output 38 columns (2 of the columns are t_stamp and tagPath).

Example output (The Min, Max, and Avg columns repeat beyond the image):

  1. Setting the columnNames, as outlined in the documentation, does not update the column names to the the provided list.
query = system.historian.queryAggregatedPoints(
	paths = tag_list,
	startTime = start_time,
	endTime = end_time,
	aggregates = aggregate_list,
	returnFormat = 'CALCULATION',
	columnNames = name_list
)

Yeah, the former appears to be the same issue described here:

And the latter is something I noticed and asked a dev on the historian team about.

Any update on the issue, with the column Names?