Dynamic report creation or merging of reports

The top-level query should be where you compile your list of parameters. In the example below I’ve basically typed my list statically, but if you have a list in SQL you can perform a real query.

QUERY (This returns one row called machines with values 1, 2, 3)

You then create a sub-query. Change the type of the sub-query to Tag Historian Query. The tag path will contain a parameter in curly braces that matches the column name from the parent query. In my case, the path is: %PATH_REDACTED%/EQUIPMENT_{machineNum}_PV. It’s important that only the path have a parameter. The Data Key Alias should not have a parameter.

My report design looks like this:

the preview looks like this (there’s another page with a chart for machine 3):

Notes: If you need to set up more than one dynamic parameter, you can accomplish this in two ways. You can increase the depth of your nest or you can select more than one column in your initial query. Keep in mind, if you don’t carefully manage the data you’re querying, nested queries can quickly start pulling in system-crashingly large amounts of data. Deeper nests are going to make this worse faster, so I’d recommend flatter nests wherever they serve your purpose.

1 Like