# Module Report - dynamic chart data key

**URL:** <https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 3, 2022, 2:31pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163 "2022-05-03T14:31:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [May 3, 2022, 2:31pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163/1 "2022-05-03T14:31:56Z")

</div>

Hi,

I use a table to create pages dynamically. My table data key “usages” is a python list containing multiple variables.  
So, for each table row (dynamic page) I would like to put a PyDataset in a timeseries chart.  
Each PyDataset is store in a variable like data1, data2, …

To automatically take the right PyDs in each table row, I store its name in each “usages” element.

Is it possible to create a dynamic dta key in a timeseries chart ?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/ca20c018284f7d15e302e96ea9696830e9508cd3.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/3840f7c4bd97b1128ea2bd1f20d7ab164b6a4be1.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e56f252824a1c305d82eaa0b43aca2a5812915a.png)

Thanks

---

<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:** [May 3, 2022, 3:05pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163/2 "2022-05-03T15:05:51Z")

</div>

I'm pretty sure you are going to need nested data. You can do this in a script if needed:

> [@Report with Scripted Nested Data](https://forum.inductiveautomation.com/t/report-with-scripted-nested-data/11801):
>
> The report datasource scripting examples explain how to access the nested data in another key for use constructing a custom dataset. What I don’t see is how to construct nested data that would be suitable for use with a child table in a table group. I have a parent dataset that I’m constructing via script due to annoying limitations of an ancient SQL Server 2000 instance. I need a subquery for each row that could be done with a normal query, but there’s no way to add a regular subquery to a s…

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [May 6, 2022, 12:37pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163/3 "2022-05-06T12:37:35Z")

</div>

Nested query create a QueryResults variable.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/a/fabda978297f9379d00cec7deaf68085a80bb353.png)

Is it possible to loop through it in a script ?

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [May 9, 2022, 1:41pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163/4 "2022-05-09T13:41:59Z")

</div>

I would like to do this like described in manual :  
[https://docs.inductiveautomation.com/display/DOC81/Charts+Inside+of+Tables](https://docs.inductiveautomation.com/display/DOC81/Charts+Inside+of+Tables)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/556e42791ef9ae890ba5ca111506ceedc14ab4c7.png)

equipment\_list and downtime\_list are basicdatasets ?  
My result below :  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/3977c1bc1051fc3504c524edf9aaf9a548d04eed.png)

My report script :

```auto
inputs = {
			'project_id':data['project_id'],
			}
	
#On génère la date d'aujourd'hui
today=system.date.setTime(system.date.now(),0,0,0)
	
#On génère le num de jour de la semaine	
todayWeekNumber = int(system.date.format(today, "u"))
	
	
# ========================================================
#On va chercher la liste des usages actifs et avec enableReport = 1
#usages = usage.getList(inputs)

usagesList = []
i=1
nested = data['usages'].getCoreResults()
	
	
for row in range(nested.rowCount):

	if nested.getValueAt(row,'state') and nested.getValueAt(row,'enableReport'):
		
		us={
		'database':data['database'],
		'unit':nested.getValueAt(row,'converted_unit'),
		'energy':nested.getValueAt(row,'physical_title'),
		'converted_unit':nested.getValueAt(row,'converted_unit'),
		'physical_title':nested.getValueAt(row,'physical_title'),
		'chart_label':nested.getValueAt(row,'chart_label'),
		'basic_unit':nested.getValueAt(row,'basic_unit'),
		'title':nested.getValueAt(row,'title'),
		'startDate':nested.getValueAt(row,'start_datetime'),
		'config':nested.getValueAt(row,'uconfig'),
		}
		
		end_datetime = nested.getValueAt(row,'end_datetime')
		
		if end_datetime is None:
			us['endDate'] = today
		else:
			us['endDate'] = end_datetime
		
		#Appel de la fonction de génère les résultats
		usData = report.makeUsageData(us)
		
		usDS = usData['outputs']['data']
		data['test'] = type(usDS)# ==> BasicDataset
	
		rowToInsert = us.values()
		headers = us.keys()
		
		rowToInsert.append(usDS)
		headers.append("downtime_list")
		
		rowToInsert.append(usData['outputs']['weeks'])
		headers.append("weeks")
		
		usagesList.append(rowToInsert)
		
data['equipment_list'] = system.dataset.toDataSet(headers,usagesList)

```

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [June 8, 2022, 3:01pm UTC](https://forum.inductiveautomation.com/t/module-report-dynamic-chart-data-key/59163/5 "2022-06-08T15:01:48Z")

</div>

Anyone can help me ?

Thanks a lot ❤
