# When a Tag used as Named Query parameter changes, data is reloaded, but not always properly

**URL:** <https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [June 14, 2019, 4:28pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836 "2019-06-14T16:28:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 14, 2019, 4:28pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836/1 "2019-06-14T16:28:31Z")

</div>

Another named query question from me.

Here’s the query I’m talking about:

```sql
DECLARE @downtimeDivisor AS INT = 1

IF :downtimeFormat = 'hours'
	SET @downtimeDivisor = 3600;
ELSE IF :downtimeFormat = 'minutes'
	SET @downtimeDivisor = 60;

SELECT TOP(:limit)
	stops.first_fault AS fault,
	COUNT(*) AS count,
	(SUM(stops.stop_duration) / @downtimeDivisor) AS downtime
FROM stop_history stops
WHERE stops.first_fault_time BETWEEN :startDate AND :endDate
		AND stops.first_fault NOT IN {hiddenFaults}
GROUP BY stops.first_fault
ORDER BY count DESC

```

My situation is this:

1. A view is showing an XY chart whose data are from this Named Query.
2. The `downtimeFormat` parameter of this Named Query comes from a tag whose value can be changed via a dropdown in another view that is a popup.
3. If I change this dropdown from `hours` to `minutes` or `seconds`, the XY chart updates properly.
4. If I change the dropdown from its current value to one that gives a smaller number (that is, from seconds to minutes, seconds to hours, minutes to hours) the XY chart does not update properly. The data refreshes, but it shows the values related to the previous dropdown selection. The XY chart’s Y-axis is also based on this `downtimeFormat` tag, and they are properly updating.

This behavior is inconsistent. Sometimes the data updates as expected, sometimes it doesn’t.

I have tried everything related to disabling caching, but I cant seem to find a way to forcibly refresh this property’s Query binding from the tag changed event, or from the dropdown change since it’s in another view.

Is there something I’m missing? I’m really not sure what is going wrong and how to get this chart data to update properly.

EDIT: Just tested to be sure, and the same behavior happens no matter if the dropdown is in the same view as the XY chart or in a different one.

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 17, 2019, 3:52pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836/2 "2019-06-17T15:52:41Z")

</div>

Another observation on this, if I set the dropdown to `seconds`, then `hours`, then `seconds` again, the seconds data is always shown, but when changing from `hours` to `seconds` the proper hours data flashes quickly on the table before being replaced by the `seconds` data.

Really not sure why this is happening, it seems like the table isn’t refreshing properly or something. Could be a bug?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 17, 2019, 4:46pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836/3 "2019-06-17T16:46:23Z")

</div>

Another update here, not sure if this is related.

I have a chart that’s controlled in exactly the same way as the first, but the first has Column series and this one has Line series. Whenever I change from `hours` to `minutes` or similarly from any setting to one that results in higher values, my line chart gets “tangled”. However, if I reload the page completely, the linechart looks fine. I’m sorting the values in my query specifically so this won’t happen.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b6de101ae0f8196563403ad1455bafc5ca904e56.png)

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 17, 2019, 7:32pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836/4 "2019-06-17T19:32:17Z")

</div>

Again, been doing more testing.

Eliminating `@downtimeDivisor` and changing it into a query parameter and assigning it using a custom property (which in turn is Map Transformed from the tag selected in the dropdown) doesn’t fix anything.

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 26, 2019, 4:05pm UTC](https://forum.inductiveautomation.com/t/when-a-tag-used-as-named-query-parameter-changes-data-is-reloaded-but-not-always-properly/25836/6 "2019-06-26T16:05:05Z")

</div>

So after some more testing.

This is being done in a VM, and the VM is kinda slow, but I noticed when running the Perspective view in my Host OS’s browser, the problem doesn’t happen. Similarly, when the VM isn’t under much load, it doesn’t happen. All my testing was done with Designer running and a Chrome browser window showing the project too.

So it seems to have to do with performance, somehow.
