# Summing partial dataset with expressions

**URL:** <https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [August 30, 2023, 3:30pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562 "2023-08-30T15:30:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_debate/32/56483_2.png) [@Alex\_DeBate](https://forum.inductiveautomation.com/u/Alex_DeBate)\
**Post date:** [August 30, 2023, 3:30pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/1 "2023-08-30T15:30:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 30, 2023, 3:33pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/2 "2023-08-30T15:33:15Z")

</div>

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](https://docs.inductiveautomation.com/display/DOC81/sum)

Otherwise you'll probably need to use a script transform.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 30, 2023, 3:59pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/3 "2023-08-30T15:59:55Z")

</div>

How are you deciding where the split is? Fixed row number?

---

<div class="post-metadata">

**Author:** ![Alex\_DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_debate/32/56483_2.png) [@Alex\_DeBate](https://forum.inductiveautomation.com/u/Alex_DeBate)\
**Post date:** [August 30, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/4 "2023-08-30T17:26:09Z")

</div>

Thanks Kevin! Scripting it is, then.

---

<div class="post-metadata">

**Author:** ![Alex\_DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_debate/32/56483_2.png) [@Alex\_DeBate](https://forum.inductiveautomation.com/u/Alex_DeBate)\
**Post date:** [August 30, 2023, 5:27pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/5 "2023-08-30T17:27:15Z")

</div>

It's a variable row number, but the amount of rows will always be even.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 30, 2023, 5:31pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/6 "2023-08-30T17:31:20Z")

</div>

So, exactly half? If you install my Simulation Aids module, this should work for you:

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

```

And the bottom half:

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

```

Should be dramatically faster than any script.

---

<div class="post-metadata">

**Author:** ![Ly17](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Ly17](https://forum.inductiveautomation.com/u/Ly17)\
**Post date:** [October 31, 2023, 4:26am UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/7 "2023-10-31T04:26:38Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 31, 2023, 7:50am UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/8 "2023-10-31T07:50:45Z")

</div>

It's called "integration toolkit" now. Use it if you can.  
If not, you can use a script:

```python
return sum(row['column_to_sum'] for row in data if row['column_to_check'] == value_to_match)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 31, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/summing-partial-dataset-with-expressions/78562/9 "2023-10-31T12:04:21Z")

</div>

You can find it on the [Module Showcase](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-integration-toolkit), on [my own website](https://www.automation-pros.com/modulesales.html), and here on the forum:

> [@Automation Professionals' Integration Toolkit Module](https://forum.inductiveautomation.com/t/automation-professionals-integration-toolkit-module/74934):
>
> 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.
