Using query tags - If the query doesn't show results - overlay problems with display indicator

I am having troubles with the results of a query tag. As a background for this discussion, I have created query tag that brings me a result after doing the query and shows a row with the value. For your reference this query tag is a dataset type.


Now I create a OPC tag that is an analog instrument pv. This will be showed at a display indicator.

So now I have two tags, and my objective is to compare these two values, normally one value is changing all the time and the other one is static most of the time. I want to show different background colors in the display indicator of the analog instrument depending if it is above or below of the target value (the query tag).

Finally I do an expression binding logic in the tag for the background and it works correctly.

The problems comes when in the query tag we didn't have any results. And when we do the comparison in the display, this show an overlay with an error.

My solution is to add in the logic of the background binding a condition when the query tag show no results but I am not sure of how to execute it.

Any idea?

Does it have to be a dataset? Can you change it to a single value return from the query?

Thanks for you quick response dear @MMaynard .

It is a dataset type because the query shows different values like diameter, identification product, description of the product, target capacity for the extruder, so finally it would be 4 columns.

So the query tag normally shows dataset 1x4. And each of these values are used in different bindings.

But anyway the problem is when I don´t have results in my query tag because sometimes they start to produce a new product and the table is not updated in that moment. So visually the indicator becomes overlay error.

I wonder how to specify in the expression binding when a tag has no results.

Use the try() expression function to provide a fallback when there's no row in the dataset. Your expression would look something like this:

try({Root}['someColumnName'], 'SomeFallback')

Do make the fallback value the same data type you expect to get from the column.


Oh. This could be a great idea. Let me try it and I will let you know the results.
Thanks @pturmel

Dear @pturmel your suggestion was effective. In fact the problem of syntax are a headache. For instance, I was using the following code:

try({[default]extrusion/productionLine1/extruder1/ext1TarCap[0,4]},"Unregistered product")

And I didn´t get the expected answer. But then with your suggestion I changed the expression as:

try({[default]extrusion/productionLine1/extruder1/ext1TarCap['finalMatDesc'],"Unregistered product")

This finally helped but the syntax problem made me waste some important time hahaha.