Summing partial dataset with expressions

Hey all,

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 expression: 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:

sum(
	transform(
		{path.to.source.dataset},
		where(
			value(),
			idx() < (len(value())/2)
		)
	),
	'someColumnName'
)

And the bottom half:

sum(
	transform(
		{path.to.source.dataset},
		where(
			value(),
			idx() >= (len(value())/2)
		)
	),
	'someColumnName'
)

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.
Thanks,

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:

That last has the most explanations and examples.