How do I write accumulated values to a label by setting the time interval? for example: daily, weekly, etc

Good Morning. I’m new to ignition and I have a question that I think is easy.
I added a Label and in its properties I put the expression:

{Machines_DM/Decorator0201/Count_MandrelTrip6_PLC}

which is an OPC-type historian tag that collects trip data from a machine chuck. In real time it gives me the number 5.
but my goal is to save this data and whenever I select a start time and end time interval (daily, weekly, monthly, yearly) from Popup Calendar and when I click uptade button the label will provide me the accumulated value depending on the range I set.
Please, look at the image below

Preformatted text

Hi Felipe, I believe there is a script on the button marked Update which should do the work that you need to display the values of each trip in your selected time frame. There should be a similar screen in your project for Bodymaker Short Cans which may provide more information.

You can just use the sum expression to sum the column of the charts dataset that contains the values you want.

https://docs.inductiveautomation.com/display/DOC80/sum

Good morning accyroy. It really has a screen with the number of short can of bodymakers. but the labels are fed by a table from the MES Analysis controller component. The script associated with the UPDATE button is this:

startTime=event.source.startDate
endTime=event.source.endDate

tags = ["machines_dm/bm0101/speed", "machines_dm/bm0102/speed", "machines_dm/bm0103/speed", "machines_dm/bm0104/speed", "machines_dm/bm0105/speed", "machines_dm/bm0106/speed", "machines_dm/bm0107/speed","machines_dm/cupper0101/speed"]
ds = system.tag.queryTagHistory(paths=tags, startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="SimpleAverage")

event.source.parent.averageSpeeds = ds
#event.source.parent.getComponent('AC_Controller').startDate = startTime
#event.source.parent.getComponent('AC_Controller').endDate = endTime
#
#event.source.parent.getComponent('Button 4').startTime = startTime
#event.source.parent.getComponent('Button 4').endTime = endTime

The problem is, I don’t want to feed direct labels from an MES Analysis Controller table, because I don’t know how to create this table, but I want to feed labels direct from an OPC tag.
Here’s how the shortcan screen you suggested I do:

OK, it looks like the BM avg speeds are being written to a possibly hidden table called averageSpeeds.
You can use the same method for your mandrel trips. But change the queryTagHistory aggregation mode to return the sum instead of average.
Create a table and call it mandreltrips then run this script on the button, you should see the results you require, then reference the individual data points the same way the BM AVG speed labels do it.

startTime=event.source.startDate
endTime=event.source.endDate
tags = ["machines_dm/decorator0201/count_mandreltrip1_plc", "machines_dm/decorator0201/count_mandreltrip2_plc", "machines_dm/decorator0201/count_mandreltrip3_plc", "machines_dm/decorator0201/count_mandreltrip4_plc", "machines_dm/decorator0201/count_mandreltrip5_plc", "machines_dm/decorator0201/count_mandreltrip6_plc", "machines_dm/decorator0201/count_mandreltrip7_plc","machines_dm/decorator0201/count_mandreltrip8_plc"]
ds = system.tag.queryTagHistory(paths=tags, startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="Sum")
event.source.parent.mandreltrips = ds
1 Like

worked perfectly!!! Thanks a lot for the help