# How to get half of a dataset with expression

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-half-of-a-dataset-with-expression/16828>\
**Category:** Ignition\
**Created:** [January 31, 2018, 7:46pm UTC](https://forum.inductiveautomation.com/t/how-to-get-half-of-a-dataset-with-expression/16828 "2018-01-31T19:46:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [January 31, 2018, 7:46pm UTC](https://forum.inductiveautomation.com/t/how-to-get-half-of-a-dataset-with-expression/16828/1 "2018-01-31T19:46:08Z")

</div>

Hi all,

I’ve got a display with a dataset parameter. I’d like to cut the dataset in half and show it in two tables using the expression language, if possible. (so half of the rows are on the left, and the other half of the rows are on the right)

Here’s a non-functional code snippet that I hope will better describe what I’m trying to do:

```auto
//the data property of a table is bound to this expression
{Root Container.myData}[0:(len({Root Container.myData})/2-1)] 
```

```auto
//the data property of another table is bound to_this expression
{Root Container.myData}[(len({Root Container.myData})/2):(len({Root Container.myData})-1)] 
```

Does anyone know how to do this?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [January 31, 2018, 7:53pm UTC](https://forum.inductiveautomation.com/t/how-to-get-half-of-a-dataset-with-expression/16828/2 "2018-01-31T19:53:07Z")

</div>

Try something using runScript -

> runScript("self.parent.myData[0:(len(self.parent.myData)/2 - 1)]")

Then something similar for the second half. I'm not sure there is a way to slice in expression alone, but IMO this is a nice second choice. Its kind of tricky to deal with runScript but for this it should be pretty simple.

---

<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:** [January 31, 2018, 8:36pm UTC](https://forum.inductiveautomation.com/t/how-to-get-half-of-a-dataset-with-expression/16828/3 "2018-01-31T20:36:13Z")

</div>

Piece of cake with the [view()](https://www.automation-pros.com/simaids/doc/expression.view.html) expression function from the [Simulation Aids Module](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids) (free!). Like so:

```auto
view("Select * Where _r < _from.rowCount/2", {Root Container.myData})

```

And then:

```auto
view("Select * Where _r >= _from.rowCount/2", {Root Container.myData})

```

If necessary, you can use the module’s debug logger to see the jython code that is produced for your expression. That can be cut and pasted into a script module for use with runScript().
