Generate a report by selecting historical tag

Hi everyone,

I am looking to create a report by selecting a historical tag, which means I would like to design a page that has a tag view component and report component if the operator selected a tag, the report would generate based on the selection

Do you have any Ideas?

You want ideas on how to set up the window and report to have this functionality? If so, my idea would be to:

  1. Create your report and add a string parameter that’ll hold your tag address(i’ll call it tagAddress), then, under Data Sources, add a Historical tag query, add a tag and under Tag Path replace the path with the parameter you’ve created: {tagAddress}. You can use default values so you can test them out while you create your report design, since what you’ll want to show on a report can vary a lot.
    Your Data tab on your report will look something like this:

  2. Use a tag browser component with “Single Selection” as the selection mode, root node pointing to the root of the folder where your tags are at, and you can use the Historical Tag Tree Mode so only your historical tags show up(Or uncheck the “Include Realtime tags” box under Real Time Tree settings.

  3. On your window, add the report viewer, point it to your report and bind the parameter for the tag address, tagAddress, to the value on the first row and column of the Selected Paths parameter on your Tag Browser tree, with an expression like this for example:

{Root Container.Tag Browse Tree.selectedPaths}[0,0]

Thank you for your help, please see attached, do I need to do something else

still not shows

This is a good approach and you are likely almost there. For troubleshooting reporting problems like this I recommend working backwards one step at a time.

For example, we would want to confirm the Design of the Report is setup to display the history from this Query. In order to confirm that you can select a single tag and hard code it in the Report Data tab. Once you see that report working in the Preview mode with a single hardcoded tag we can move onto making the Query dynamic via a Parameter.

To verify the report parameter is working: I would recommend first selecting a tag in the Report Data tab and copying that entire Tag Path. Hardcode that Tag Path string in the “tagAddress” Report Parameter on the Report Viewer component. If that works, then the problem would be isolated down to the dynamic path being passed.

1 Like

I’ve tried recreating my steps and at first no data showed up, i was confused until i realized that i’ve set the EndDate a few hours BEFORE StartDate, maybe it’s something simple as that. Otherwise i’m afraid you’ll have to start troubleshooting like @kvane described.

1 Like

Looks like is working on first step

I was recommending hard coding the tag within the actual Query itself, like so:

This will allow you to design your report and test in the preview tab with valid history data. When testing history in the Report it is common to use a Table component. You would set the Data Key to “tag_history” and then you can drag in the columns from the Key Browser. For example:

Once the report is showing some history data and working as you would expect, then move to the Parameter and Vision Window design.

In the recent screenshots it looks like you are actually reading a tag in the tagAddress expression and it is returning the value “0”. In expressions make sure you put quotes around anything that needs to be treated as a string. For example, if I were to hard code my tag path as a string it would look like: “[DB]stations/station 1/flow rate”

1 Like


Still not showing historical data

Also, I don’t know why the timestamp is only date

I need detail hh:mm:ss

Thank you so much for your help, what did you use for the default value on tagAddress ?

Note the order I recommended creating the report design in: set the Data Key, and then drag in the columns. The columns should show @feso_flow@ and @t_stamp@ , right now they are effectively being set to only return the first value for the Query.

For the timestamp format, edit the “Properties” on the component in the design tab and change the “Date Fromat” property to the format desired. You can click on individual columns within the table:


1 Like

Thank you for your prompt reply, Yes

Now I have some historical data

For passing parameter, I don’t know what I have put on my parameter default value and what I have to put in my report s parameter pass

Excellent. For the parameter: It does not matter what the default value is, because on the Report Viewer component you will have a binding or script that overwrites that parameter.

First, copy that “Tag Path” directly from the Query Data Source and record it somewhere. Then, put back the dynamic Tag Path back you had already in the report data tab: {tagAddress}. After that navigate to the Vision Window, and you can now paste that tag path into the Report Viewer component’s “tagAddress” parameter. Finally, adjust the start and end date on the component and confirm you are seeing data as expected.

Once you reach that point, you now have a dynamic report setup and the final step would be ensuring you have some sort of script or expression that updates the “tagAddress” parameter on the component with the tag path that should be displayed. If the Tag Browse Tree is set to historical mode, then the expression offered earlier by Leonardo would be a good start.

1 Like

Thanks for Your Help
Still, I am not able to generate a dynamic report

At this point it is likely Python syntax errors getting in your way. I would recommend reading the “Details” section of that error.

Adding Print statements to the script may be the most helpful thing to do. We have a document page that outlines Python Troubleshooting here: Basic Python Troubleshooting - Ignition User Manual 8.1 - Ignition Documentation

1 Like

The problem is: the button is not recognized tagAddress

That is not enough description to understand the script error.

The forums are not an ideal place for Support of this level. Consider contacting Inductive Automation Support and they can review the error you are seeing.

1 Like

I have a question

How can I show my tag name in the report?
how I can access the tag name in script

If you’re still using the tagAdress as the parameter that contains your tag, and your tag name is the last part of your string, you can add a script DataSource with this code in it:

data['tagName']= data['tagAddress'].split('/')[-1]

I couldn’t think of an easy way to do this via expression, but this should work at least.

1 Like