Dataset Expression Row Count

I have a dataset and I would like to check to see if the dataset contains any rows in an expression binding. I know to access the dataset values, you use “Dataset_Expression [x,y]”. Is there a way to check how many rows are in the dataset, similar to data.getRowCount()?

You should be able to check the row count of a dataset in the expression language by simply using the len() function:

len({referenceToDataset})
3 Likes

Note that this capability of the len() expression is new in 8.1.8, for any users still on an older version.

Do you mean somewhere it broke and was fixed for 8.1.8? Because this functionality goes way back.

I think he’s mixed up adding expanded support for arrays and collections. Looks like the len function has supported DataSets for a long time.

3 Likes

How to get the length of a disticnt column values inside a dataset ?

All the columns will have the same length and this will be the length of the dataset.

Are you asking how to get the maximum string length in a particular dataset column? (If so then this should have been asked as a new thread as it is not related to this one.)

2 Likes

Can I use python's len function to do the same thing within a script?

I'm not sure, I would probably just stick with the default dataset scripting functions in Ignition:

dataset.getRowCount()
1 Like

Not for any arbitrary dataset. PyDatasets, yes.

Slightly more efficient, and easier on the eyes:

dataset.rowCount
3 Likes