How to get half of a dataset with expression

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:

//the data property of a table is bound to this expression
{Root Container.myData}[0:(len({Root Container.myData})/2-1)] 
//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!

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.

1 Like

Piece of cake with the view() expression function from the Simulation Aids Module (free!). Like so:

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

And then:

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().