# Weird issue with report script data source (dataset)

**URL:** <https://forum.inductiveautomation.com/t/weird-issue-with-report-script-data-source-dataset/23826>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 3, 2019, 8:09pm UTC](https://forum.inductiveautomation.com/t/weird-issue-with-report-script-data-source-dataset/23826 "2019-04-03T20:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul.bouillon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.bouillon/32/7980_2.png) [@paul.bouillon](https://forum.inductiveautomation.com/u/paul.bouillon)\
**Post date:** [April 3, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/weird-issue-with-report-script-data-source-dataset/23826/1 "2019-04-03T20:10:00Z")

</div>

Hi All,

Trying to understand why I’m only getting a single row returned from my datasource created by script…

Essentially, I am trying to sum the rows of my nested query, so that I can display a pie chart – was trying to avoid executing a second (non-nested) query to obtain data that I already have…

```auto
	# combine all of the skip delay reasons into a single datasource for aggregation (e.g. category pie charts, etc)
	reasons = data['skip_delay'].getNestedQueryResults()['reasons']
	
	category_delay = {}
	
	for child in reasons:
		child_r = child.getCoreResults()
		for row in range(child_r.rowCount):
			category = child_r.getValueAt(row,'category')
			delay = child_r.getValueAt(row,'delay')
			if delay:
				if category in category_delay:
					delay = category_delay[category] + delay
				category_delay[category] = delay
	

	headers = ['category','delay']
	ds_data = []
	for k in category_delay:
		ds_data.append([k,category_delay[k]])
		
	data['reasons'] = system.dataset.toDataSet(headers,ds_data)
	data['debug'] = data['reasons'].getRowCount()

```

From here – i would expect the row count of my “reasons” ds to be the same as my “debug” parameter… but for whatever reason – this is what I get:  
 ![report%20designer](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/253eea45ba44502a5eebcb8f46f18b1344d3bc9b.png)  
and in the preview…  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/446b1eacf880160d1cf472bad91a9d6a190580f1.png)

Nothing is logged in the output console or gateway logs that I can see…

Perhaps I’m missing something here? Has anyone seen this behaviour before/have troubleshooting tips?

This gateway version is 7.9.1.

Thanks in advance!

-Paul

---

<div class="post-metadata">

**Author:** ![paul.bouillon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.bouillon/32/7980_2.png) [@paul.bouillon](https://forum.inductiveautomation.com/u/paul.bouillon)\
**Post date:** [April 3, 2019, 9:06pm UTC](https://forum.inductiveautomation.com/t/weird-issue-with-report-script-data-source-dataset/23826/2 "2019-04-03T21:06:05Z")

</div>

another classic case of the good ol’ post and solve immediately – hope this doesn’t become my thing… but it’s hard to argue with the results…

there be some weird internal issue with how datasources are named/do not get rendered properly with respect to heirarchy/scope…

took a random stab, and just renamed my ‘reasons’ datasource to ‘category delays’…

```auto
data['category delays'] = system.dataset.toDataSet(headers,ds_data)
# data['debug'] = data['reasons'].getRowCount()

```

…perhaps the name ‘reasons’ was clashing with the nested query referenced above?

anyways – hope this helps someone else in the future! 🙂

-Paul
