I've got a dataset stored in a component's custom prop. I'm trying to have another pair of property bindings do the following: property 1 sums the first half of the dataset and property 2 sums the second half of the dataset. Is this possible to do with expressions, or should I iterate through it with a script transform?
If your dataset has half its values in one column and half in another, you could probably use the
sum - Ignition User Manual 8.1 - Ignition Documentation
Otherwise you'll probably need to use a script transform.
How are you deciding where the split is? Fixed row number?
Thanks Kevin! Scripting it is, then.
It's a variable row number, but the amount of rows will always be even.
So, exactly half? If you install my Simulation Aids module, this should work for you:
idx() < (len(value())/2)
And the bottom half:
idx() >= (len(value())/2)
Should be dramatically faster than any script.
Hi, where do I find your Simulation Aids module? I think this would be very useful for what I'm trying to do. I'm trying to sum all rows in a column where the value in a different column is met.
It's called "integration toolkit" now. Use it if you can.
If not, you can use a script:
return sum(row['column_to_sum'] for row in data if row['column_to_check'] == value_to_match)
You can find it on the
Module Showcase, on my own website, and here on the forum:
Automation Professionals is pleased to announce the immediately availability of a major upgrade to its free Simulation Aids Integration Toolkit module. The new feature justifying the "major upgrade" language is the implementation of eleven new expression functions which use iteration to accomplish complex transforms of datasets and lists, to or from other datasets and lists, applying filtering, ordering, and computed new columns along the way. While there are certain operations that are still …
That last has the most explanations and examples.