# Comparing Tag Values Senior Moment

**URL:** <https://forum.inductiveautomation.com/t/comparing-tag-values-senior-moment/41579>\
**Category:** Ignition\
**Created:** [December 16, 2020, 7:15pm UTC](https://forum.inductiveautomation.com/t/comparing-tag-values-senior-moment/41579 "2020-12-16T19:15:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.stevic](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@thomas.stevic](https://forum.inductiveautomation.com/u/thomas.stevic)\
**Post date:** [December 16, 2020, 7:15pm UTC](https://forum.inductiveautomation.com/t/comparing-tag-values-senior-moment/41579/1 "2020-12-16T19:15:00Z")

</div>

I seem to always make simple this more complicated that they should be. I have two tags. The first tag runs a query that gits the number if event over the last minute (represents a feed rate). The second tag stores the fastest rate achieved during a shift.

When the first tag value is greater than the second tag, the faster rate is stored in the second tag, if the current rate is slower than the maximum, the second tag is not changed.

DD\_231\_current (the first tag) working query is:

SELECT COUNT(DD\_231) FROM dockDoorInducts  
WHERE currentTime \> DATE\_ADD(NOW(), INTERVAL -1 MINUTE);

DD\_231\_Peak (the second tag) nonworking expression is:

if (({[.]DD\_231\_Current} \>= {[.]DD\_231\_Peak}), {[.]DD\_231\_Current}, {[.]DD\_231\_Peak})

I have tried various combinations of parentheses and groupings. The errors I get are :  
“if function got a null first argument” and “Error Configuration”

I am using 8.0.12

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 16, 2020, 7:37pm UTC](https://forum.inductiveautomation.com/t/comparing-tag-values-senior-moment/41579/2 "2020-12-16T19:37:17Z")

</div>

```auto
if(
	{[.]DD_231_Current} >= {[.]DD_231_Peak},
	{[.]DD_231_Current},
	{[.]DD_231_Peak}
)

```

Looks like the logic is correct, but I’m guessing the comparison operator is failing because the tags are briefly null during tag initialization. You could try wrapping it all in a `try`; change the `1` to `0` if you want to default to using Peak instead of Current:

```auto
if(
	try({[.]DD_231_Current} >= {[.]DD_231_Peak}, 1),
	{[.]DD_231_Current},
	{[.]DD_231_Peak}
)

```
