# Hey i have some issue with coding

**URL:** <https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 1, 2023, 2:39pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443 "2023-06-01T14:39:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 1, 2023, 2:39pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/1 "2023-06-01T14:39:51Z")

</div>

I have 3 imput field, every day i must count sum of this field  
Everyday i must reset value to 0, in 23:00 it must hapend.  
In need of the month we need to sum of every day, and in end of year i need to calc sum of 12 month.  
This 3 value must be writed into the tags. All miust be writed by skripting.  
Thans for the response

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 1, 2023, 2:46pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/2 "2023-06-01T14:46:00Z")

</div>

> [@Vitaliy\_Galiy](#):
>
> All miust be writed by skripting

Why?

Honestly the majority of this task is better handled in the device. Do you not have access to the program?

Even then why not use tag history or some other type of history, or is that really what you're trying to produce?

> [@Vitaliy\_Galiy](#):
>
> I have 3 imput field, every day i must count sum of this field

Do you have three inputs or one? What are the data types of the inputs?

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 1, 2023, 2:57pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/3 "2023-06-01T14:57:39Z")

</div>

Could u show how i can do it by another method  
I have 3 imput, they all int, I also need to put this data to database(MySQL)

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 1, 2023, 3:01pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/4 "2023-06-01T15:01:19Z")

</div>

If I use tag history, how I can do this?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 1, 2023, 3:08pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/5 "2023-06-01T15:08:10Z")

</div>

Maybe this post will give you some guidance,

> [@Tag history difference over interval](https://forum.inductiveautomation.com/t/tag-history-difference-over-interval/48366):
>
> I am trying to find a better way to do production counts over specific intervals using tag history. Example, I have a tag TestCount, right now it’s a memory tag, but typically this would be an OPC tag from a PLC that increments. I can’t use Count aggregationMode because it may not “catch” each transition, example, it may go from 10 to 13. My desire is to be able to chart this data over a period of time, example, 12 hours, with a certain interval, example 1 hour. So, if at the start of the ho…

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 1, 2023, 3:10pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/6 "2023-06-01T15:10:36Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 1, 2023, 3:13pm UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/7 "2023-06-01T15:13:25Z")

</div>

Let's take a step back.  
What are you trying to do ? And I don't mean "summing fields and storing the data", I mean the end goal - what is this supposed to achieve ?

Then, some more details are required:  
What exactly do you need to sum ? The three fields together ? Each field with itself when a new value is entered ?  
When do you need to sum them ? At 23:00 everyday ?

The whole thing raises a lot of questions. Try to be as specific as possible.

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 2, 2023, 6:11am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/8 "2023-06-02T06:11:21Z")

</div>

I have 3 data inputs, I need to write a code that will accept these 3 inputs and calculate their sum, every day at 23:00 I need to update the input value to 0 so that I can enter data again.  
Then I need to find the sum of all 3 inputs for all days of the month at the end of the month. At the end of the year, you need to take the sum of all months.

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 2, 2023, 6:12am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/9 "2023-06-02T06:12:41Z")

</div>

Sorry  
I am not a native English speaker and a beginner in ignition

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [June 2, 2023, 7:06am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/10 "2023-06-02T07:06:12Z")

</div>

Read the manual. You just need Gateway Event Scripts.  
Create several tags for your inputs and sums.  
[https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 7:07am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/11 "2023-06-02T07:07:00Z")

</div>

No problem here. We just have to make sure we understand what you're asking, which is why I'm asking questions.

One more clarification:  
Should the sum be calculated at the same time the fields are reset ?  
I'd specifically want to know if it should be calculated only once a day, with the current values, or if the calculation happens multiple times through the day.

Also, I still suggest you try to explain the goal of this, because maybe there are better ways to do it, that are hidden by the solution you're already trying to implement.

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 2, 2023, 7:47am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/12 "2023-06-02T07:47:56Z")

</div>

Yeah, sum should calculated at the same time after fields sre reset.  
It should calculated once a day.  
This is automation for the company, data will be recorded here on how much certain workers did per day.  
Thank you

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 8:12am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/13 "2023-06-02T08:12:44Z")

</div>

How are the values entered in those fields ? Is it done manually ?

I'd use 3 tags bidirectionally bound to the input fields, then a timer script that would fetch those 3 values, sum them up, then store that in a database with the date.  
Every month, you can query that database to sum up the last month's values, and every year sum up the last year's values.

---

<div class="post-metadata">

**Author:** ![Vitaliy\_Galiy](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vitaliy\_Galiy](https://forum.inductiveautomation.com/u/Vitaliy_Galiy)\
**Post date:** [June 2, 2023, 8:20am UTC](https://forum.inductiveautomation.com/t/hey-i-have-some-issue-with-coding/74443/14 "2023-06-02T08:20:27Z")

</div>

We use 3 LED Display which have popup window. So we take data from this popup window.  
Can u show some exaples how i can do this.
