# Script error in reporting module

**URL:** <https://forum.inductiveautomation.com/t/script-error-in-reporting-module/67760>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 18, 2022, 7:43am UTC](https://forum.inductiveautomation.com/t/script-error-in-reporting-module/67760 "2022-12-18T07:43:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Mejia](https://avatars.discourse-cdn.com/v4/letter/w/71e660/32.png) [@William\_Mejia](https://forum.inductiveautomation.com/u/William_Mejia)\
**Post date:** [December 18, 2022, 7:43am UTC](https://forum.inductiveautomation.com/t/script-error-in-reporting-module/67760/1 "2022-12-18T07:43:37Z")

</div>

I am making a script to create a simple dataset where one column is the name of the product and the other is the weight. I choose this weight using system.tag.queryTagHistory and I save it in a variable to later use it when creating the dataset.

def updateData(data, sample):

```
dropDownMill = data['dropDownMill']
startTime = data['startTime']
endTime = data['endTime']
intervalTime = system.date.hoursBetween(startTime, endTime)

pathScaleB1 = '[Scales_Simulator]' + dropDownMill + '/scale b1/pv_totalweightnotclearable'
value = system.tag.queryTagHistory(paths=[pathScaleB1], startDate=startTime, endDate=endTime, intervalHours=intervalTime, aggregationMode="Range")

headers = ["Products", "Weight"]
row = []
row.append(["B1", value])
ds = system.dataset.toDataSet(headers, row)
data['MyDataset'] = ds

```

When I go to the design tab I get an error, I attached images.

 ![Captura de pantalla 2022-12-18 022339](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2a4165749d6a1fc08bd0b1c24a92e4b1cde1bca.jpeg)  
 ![Captura de pantalla 2022-12-18 022228](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8ce4c4fd076a9f8ef581d5a57f5f19139a5d43d1.jpeg)  
 ![Captura de pantalla 2022-12-18 021958](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/2/12bfd4641152e21490a2efd436fb276f9c4bd9d0.jpeg)

---

<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:** [December 18, 2022, 1:52pm UTC](https://forum.inductiveautomation.com/t/script-error-in-reporting-module/67760/2 "2022-12-18T13:52:29Z")

</div>

You are placing a dataset inside of a dataset. `queryTagHistory()` returns a dataset. Which you then place into a row of your scripted dataset. Not permitted. The error is occurring when the gateway is trying to deliver this invalid dataset to the designer for you.

Extract the value from the history dataset to place in your row.

---

<div class="post-metadata">

**Author:** ![William\_Mejia](https://avatars.discourse-cdn.com/v4/letter/w/71e660/32.png) [@William\_Mejia](https://forum.inductiveautomation.com/u/William_Mejia)\
**Post date:** [December 19, 2022, 12:04am UTC](https://forum.inductiveautomation.com/t/script-error-in-reporting-module/67760/3 "2022-12-19T00:04:27Z")

</div>

Thanks for the help, it was very useful!! I fixed it by adding B1 = value.getValueAt(0,1)

```
dropDownMill = data['dropDownMill']
startTime = data['startTime']
endTime = data['endTime']
intervalTime = system.date.hoursBetween(startTime, endTime)

pathScaleB1 = '[Scales_Simulator]' + dropDownMill + '/scale b1/pv_totalweightnotclearable'
value = system.tag.queryTagHistory(paths=[pathScaleB1], startDate=startTime, endDate=endTime, intervalHours=intervalTime, aggregationMode="Range")
B1 = value.getValueAt(0,1)

headers = ["Products", "Weight"]
row = []	
row.append(["B1", B1])
ds = system.dataset.toDataSet(headers, row)
data['MyDataset'] = ds

```
