Expressiond.binding when table result is empty

I have a SQL query bringing a simple dataset into a custom property. I did it via dataset just because I wanted to use SQL to get the latest recorded value (order by XYX desc limit 1 kind of thing). From that single row dataset, I want to bind and show the values. The problem is that sometimes (often), the query returns NO rows. This is normal and expected. The issue is, I can’t get the expressions using the dataset (like[“user”]) to stop faulting out on index out of range…
Any help appreciated.

Bit of an update- I found that if I query the two fields separately I can handle the issue with fallback value. So “crisis” over…but it would be good to know if there is a way around the original issue.

Yes, there’s a couple ways. The easiest way is to use the “try” function like this:

try(["user"], "")

If an error occurs then it is suppressed and the second value (a blank string) is returned.

Here is another way:

if(len( > 0,["user"], "")

If the dataset has more than 0 rows then get the “user” value from the dataset otherwise get the second value (a blank string).

Nick Mudge