Combining datasets


I have 9 datasets in the root container of a window and each dataset has two columns; ‘item’ and ‘value’. I want to combine these to one dataset. How do I do this?

Note: each dataset is bound to a rather complicated query that I would prefer not to mess with.
Translation: I am too lazy to change it and I am looking for an easier way.

Thank you,

It is a little tricky since you cannot combine datasets in binding, you have to do it in scripting. You can put a propertyChange script on the Root Container that if any of the datasets change you can create a new combined one. Add the following code to a propertyChange script of the Root Container:[code]if event.propertyName == “ds1” or event.propertyName == “ds2”:
ds1 = event.source.ds1
ds2 = event.source.ds2
header = [“Item”, “Value”]
data = []

def addData(ds):
	import system
	data = []
	for row in system.dataset.toPyDataSet(ds):
		data.append([row[0], row[1]])
	return data


event.source.combined = system.dataset.toDataSet(header, data)[/code]You can add more than just two datasets ds1 and ds2. This code goes through and creates a whole new dataset out of the previous ones and sets it to the combined dataset on the Root Container in my case.

Thank you, it works great! :thumb_left:

You can also use a union. You don’t have to mess with the queries, just cut/past them all into one with a UNION between each.