I have a label, and just simply bind its' text property to a tag with dataset value
the expression binding is something like below, this tag with a Dataset [24R x 4C] value, I just use a specific cell [0,3]. The syntax is right and everything seems ok.
{path_to_my_tag.value}[0,3]

The strange thing is that, when I close this vision window and reopen it in designer, at the first moment, the designer reports an error as below:
but the text value is correct displayed in this label. It's quite annoying and I just update the binding expression as below:
try(
{path_to_my_tag.value}[0,3],
'error'
)
the error message disappears when I close and re-open it, and no 'error' text displayed in this label.
It seems this binding cannot get the value in first moment when open this window, but just after that moment it can get value successfully. Does anyone know the reason for this?
I suspect you’re right and the expression initially tries to subscript a dataset that hasn’t loaded yet.
Try {your/tag[0,3]}
instead
1 Like
Awesome! Your suggestion works. Thank you!
I read the document, the methods to access the data in dataset when using expression is as below.
Dataset_Expression ["Column_Name"] //Returns the value from the first row at the given column name.
Dataset_Expression [Column_Index] //Returns the value from the given column at the first row.
Dataset_Expression [Row_Index, "Column_Name"] //Returns the value from the given row at the given column name.
Dataset_Expression [Row_Index, Column_Index] //Returns the value from the given row at the given column index.
This is the first time I know can use the method as you suggested.
It seems below two methods both workable and it seems the latter one is much better for my case.
{path_to_dataset_tag.value}[Row_index, Column_Index]
{path_to_dataset_tag[Row_index, Column_Index]}
I would expect them not to do the same thing.
The first one would read the full tag, then apply the subscript.
The second one would only read the specified row/column.
Which explains why the first one raises an error before the tag is read.
Also, I'd expect the second one to be faster, even if only slightly.
Yes, your explanation is clear and make sense!
One more thing:
You probably should be using a tag binding, not an expression binding:
Yes, you are right. If only use a cell value from dataset, use tag binding directly is much easier
For my actual case, I just use expression to apply more logics to that value.
It might still be worth it to have a custom property read that value with a tag binding, then post-process it in the label's binding.
But wait for someone else's opinion on this, I'm not well versed in this kind of things.