Try expression not getting rid of Error_Type configuration on Numeric Text Label?

Using 8.0.17.

I have a dataset with a column totalAmount of type double
image that resides in a table.

Underneath said table I have a numeric text label that sums up the total with an expression on the value property sum({Root Container.Table_Invoices.data},"totalAmount").

When there is data in the table, it works as expected, but when a filter is applied to the data and there are no rows, I get a red overlay and the diagnostic telling me there is a Error_TypeConversion.
image

I tried wrapping the expression with a try(sum({Root Container.Table_Invoices.data},"totalAmount"), 0), but that did not work. I can’t check the type of the column either when there are no rows in it
image
which makes sense, how can no data have a type. But I thought the try would catch this error on it’s own.

This seems like it would be a common thing - using sum() on a dataset in a numeric text field and the possibility of there being no data in the dataset.

Right now my workaround is if(len({Root Container.Table_Invoices.data})=0, 0, sum({Root Container.Table_Invoices.data},"totalAmount")) but I feel like there should be a better way. I don’t know if this was an issue that was resolved in a updated version, but I think it would be nice if the try expression caught the Error_TypeConversion error so it would not have to be done that way. I was under the impression that try caught all errors so I was a little surprised when this one slipped through.

I hope I provided enough context to recreate this error but I can give more details if required. If someone could tell me the “proper” way, or if this is expected behavior, or if it was a bug that was solved in a newer version, please let me know.

The sum itself is working, it’s just returning a null value. Try:

coalesce(sum({Root Container.Table_Invoices.data}, 'totalAmount'), 0)

1 Like

Ah interesting, so the error is not coming from the sum, so that’s why try is not doing anything. It was confusing me for a while - how are you having a red overlay, you clearly have an error, but are not showing the failover value form the try?

That’s good info to know.

It’s something that may have gotten me once… maybe twice… okay, no more than three, tops. :wink:

2 Likes