# Reporting: combine data sources via scripting for chart dataset

**URL:** <https://forum.inductiveautomation.com/t/reporting-combine-data-sources-via-scripting-for-chart-dataset/19803>\
**Category:** Ignition\
**Created:** [September 25, 2018, 9:58am UTC](https://forum.inductiveautomation.com/t/reporting-combine-data-sources-via-scripting-for-chart-dataset/19803 "2018-09-25T09:58:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanko25](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vanko25](https://forum.inductiveautomation.com/u/vanko25)\
**Post date:** [September 25, 2018, 9:58am UTC](https://forum.inductiveautomation.com/t/reporting-combine-data-sources-via-scripting-for-chart-dataset/19803/1 "2018-09-25T09:58:34Z")

</div>

Hi all,

I am having a report that I need to do for a client. I have various SQL queries that return single values to populate text boxes on the report. A pareto bar chart is also required to visually represent these values. Instead of creating another SQL query I am trying to combine the data into data set in the follwing way:

```auto

> headers = ["name","value"]
> rows = [["Baggers Loses",BaggersLoses],["Cartoner Loses",CartonerLoses],
> ["Packer Loses",PackerLoses],["Conveyor Loses",ConveyorLoses]]
> data = system.dataset.toDataSet(headers,rows)
> newData = system.dataset.sort(data, "value",0)
> #Select Chart object and apply newly created dataset to it
> data['Data_Stops'] = newData

```

Where all the values are predefined in the script and “Data\_Stops” is empty DataSet parameter. The error that I get is as follows:

```auto
WARN: Error invoking script.Traceback (most recent call last):
  File "<function:updateData>", line 60, in updateData
TypeError: 'com.inductiveautomation.ignition.common.BasicDataset' object does not support item assignment

```

Anyone can guide me in the right direction where I am getting it wrong?

---

<div class="post-metadata">

**Author:** ![vanko25](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vanko25](https://forum.inductiveautomation.com/u/vanko25)\
**Post date:** [September 25, 2018, 10:38am UTC](https://forum.inductiveautomation.com/t/reporting-combine-data-sources-via-scripting-for-chart-dataset/19803/2 "2018-09-25T10:38:04Z")

</div>

I got to the solution by myself using the following code:

```auto
    toPyDS = system.dataset.toPyDataSet
	xDataSet = toPyDS(system.dataset.toDataSet(['x'], [['Baggers Loses'],['Cartoner Loses'],['Packer Loses'],['Conveyor Loses']]))
	yDataSet = toPyDS(system.dataset.toDataSet(['y'], [[BaggersLoses],[CartonerLoses],[PackerLoses],[ConveyorLoses]]))
	xs = [str(row[0]) for row in xDataSet]
	ys = [float(row[0]) for row in yDataSet]
	rows = zip(xs, ys)
	xyDataSet = system.dataset.toDataSet(['x', 'y'], rows)
	data['Data_Stops'] = xyDataSet

```
