# XY Chart query binding run twice every time

**URL:** <https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 5, 2024, 5:51am UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151 "2024-08-05T05:51:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 5:51am UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/1 "2024-08-05T05:51:13Z")

</div>

Good morning,

I have a problem, in my specific case with a XY Chart. I fill it up with a query binding where I pass 3 parameters:

1. StartDate (DateTime)
2. EndDate (DateTime)
3. Department (Int4)

The problem is that when I select the StartDate or the EndDate, both of them change accordly with the shift so the query run twice, I guess because both are updated. For example if I change the StartDate, the EndDate will change automatically and viceversa.

What could I do to prevent it?

---

<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:** [August 5, 2024, 1:20pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/2 "2024-08-05T13:20:39Z")

</div>

> [@Aiasa21](#):
>
> both of them change accordly with the shift

Do you mean that you have 2 date pickers, and picking the date from one changes the date from the other, using some shift duration to do date arithmetic ?  
If that's the case, you have redundant information, which indeed will make the binding update twice.

Is the shift duration fixed, or is it pulled from somewhere ?

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/3 "2024-08-05T18:54:20Z")

</div>

Yes the 2 data pickers are 2 of the 3 parameters of the named query.

The problem is that the shift is fixed but you can even choose a daily view or other options.

I think that even if I pass only one parameter (maybe concatenating together the 2 date) I will have the same problem right?

There's no option in the binding to prevent a double binding in a very short time?

---

<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:** [August 5, 2024, 7:50pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/4 "2024-08-05T19:50:19Z")

</div>

> [@Aiasa21](#):
>
> I will have the same problem right?

No, if you remove one of the date pickers then you will only have a single property triggering the binding.

I would not concatenate the two together. Make one date an offset of the other.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 7:54pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/5 "2024-08-05T19:54:20Z")

</div>

I can't remove one of the data picker, I was thinking about passing a single parameter maybe with a custom properties of the 2 data pickers together.

Unfortunately the offset is not fixed.

Normally I have about 100 columns to show in the xy chart, but I have a specific department where there are 7-800 columns and load it twice is not the best.

---

<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:** [August 5, 2024, 7:55pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/6 "2024-08-05T19:55:02Z")

</div>

> [@Aiasa21](#):
>
> I can't remove one of the data picker

Why not?

This statement:

> [@Aiasa21](#):
>
> The problem is that when I select the StartDate or the EndDate, both of them change accordly with the shift so the query run twice

Indicates that one time is dependent upon the other. That means that you only need one date picker.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 5, 2024, 7:59pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/7 "2024-08-05T19:59:36Z")

</div>

I usually use a datepicker for either a start or end date and a dropdown or radio group to select  
Period: (o) 1 day ( ) 7 days ( ) 14 days 28 days  
or whatever.  
It means that once the period length has been selected the datepicker is only used once.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 8:13pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/8 "2024-08-05T20:13:11Z")

</div>

I have this cases:

1. Shift offset
2. Daily offset
3. Custom offset

The first 2 are selected by arrow and checkbox and depending of these the offset is 8 hours or 24 hours, the 3rd option is selected choosing start and end datetime manually.

---

<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:** [August 5, 2024, 8:17pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/9 "2024-08-05T20:17:19Z")

</div>

> [@Aiasa21](#):
>
> 3rd option is selected choosing start and end datetime manually.

Why not a start date and a number of hours, or minutes, or seconds, or even a combination?

Or even, use an expression with both of the date time pickers and calculate the offset, and use the offset in your binding, as opposed to the two different dates.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 8:18pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/10 "2024-08-05T20:18:49Z")

</div>

This could be an idea..

What about this… using the

> system.util.invokeLater

function to pass after maybe 100ms one single parameter to the named query and then manipulate this to extract start date and end date separately?

---

<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:** [August 5, 2024, 8:19pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/11 "2024-08-05T20:19:51Z")

</div>

> [@Aiasa21](#):
>
> system.util.invokeLater

Only available in Vision Client scope, not perspective.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 8:23pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/12 "2024-08-05T20:23:49Z")

</div>

Yes are all ideas, the starting point for me is to keep the things exactly as they are now, because is 25 years that people in production are used to run it with 2 data pickers so I would like to continue to keep in this way..

But I need to find a solution at this problem, because is crazy to load the same data twice with no reason.

I appreace all your helps, thank you guys

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 5, 2024, 8:24pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/13 "2024-08-05T20:24:08Z")

</div>

Oh ok, thanks

---

<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:** [August 5, 2024, 8:27pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/14 "2024-08-05T20:27:22Z")

</div>

> [@Aiasa21](#):
>
> But I need to find a solution at this problem, because is crazy to load the same data twice with no reason.

The solution is quite simple. Don't tie both date pickers to the same binding which triggers the query. That's it, that is the only solution. There are multiple ways to arrive at that.

I wouldn't oppose change just because it's different. Just because something works doesn't mean there isn't a better solution.

---

<div class="post-metadata">

**Author:** ![Kevin\_Flener](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kevin\_Flener](https://forum.inductiveautomation.com/u/Kevin_Flener)\
**Post date:** [August 5, 2024, 8:54pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/15 "2024-08-05T20:54:13Z")

</div>

I'm still a beginner with this stuff, so I hope I don't embarrass my self too much...

Could you use custom properties to pass the information to your query, and then have a script on a button's OnActionPerformed event to update the custom properties based on the values of the two date pickers?

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 5, 2024, 9:27pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/16 "2024-08-05T21:27:31Z")

</div>

What @Kevin_Flener said....or you could also display the start/end time as a label or button. On press, bring up a popup window to choose your start and end times (along with your other selections). When you click OK on your popup window, send a message to your main screen to update some custom start/end properties that are bound to your XY Chart.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 5, 2024, 10:28pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/17 "2024-08-05T22:28:24Z")

</div>

> [@Aiasa21](#):
>
> There's no option in the binding to prevent a double binding in a very short time?

Sadly, this is something that Vision's query bindings and Chart pens do (10ms? 50ms? something like that) that didn't get ported over to Perspective. ☹

Or maybe it is a side effect of Vision's single UI thread and the asynch nature of query bindings. But the end result is that Vision coalesces multiple reference changes that feed into another binding. Perspective doesn't.

I think this would be worth putting up as a feature request.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 6, 2024, 5:56am UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/18 "2024-08-06T05:56:23Z")

</div>

> [@pturmel](#):
>
> Sadly, this is something that Vision's query bindings and Chart pens do (10ms? 50ms? something like that) that didn't get ported over to Perspective. ☹
> 
> Or maybe it is a side effect of Vision's single UI thread and the asynch nature of query bindings. But the end result is that Vision coalesces multiple reference changes that feed into another binding. Perspective doesn't.
> 
> I think this would be worth putting up as a feature request.

Yes, that's what I mean.. It looks strange that this feature is not in Perspective..

As you guys suggested there are a lot of workaround to "fix" this problem but they are not **the** solutions, I mean add a button or add a dropdown is something more that the operators must do check the departments status and in terms of enhancing the tool, this is a step backward.

---

<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:** [August 6, 2024, 11:36am UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/19 "2024-08-06T11:36:16Z")

</div>

> [@Aiasa21](#):
>
> I mean add a button or add a dropdown is something more that the operators must do check the departments status and in terms of enhancing the tool, this is a step backward.

Sorry, but how is adding a button or a dropdown in lieu of a date picker "adding" something for the operators to do? You would be replacing one action with another.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [August 6, 2024, 12:13pm UTC](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151/20 "2024-08-06T12:13:26Z")

</div>

You are absolutely right, let's say that I understand the group's choice to keep everything as it has been for the last 25 years to ensure continuity even in the case of a revamp.

In any case, if there is no solution to the problem of double execution (even though, as suggested by @pturmel, it might be a "problem" that Inductive Automation could consider addressing), I obviously have to think of something different, probably substituting the date picker with a dropdown menu.

[Next page](https://forum.inductiveautomation.com/t/xy-chart-query-binding-run-twice-every-time/94151.md?page=2)
