# Report Script Data Source Help

**URL:** <https://forum.inductiveautomation.com/t/report-script-data-source-help/112986>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting, reporting\
**Created:** [December 24, 2025, 4:11pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986 "2025-12-24T16:11:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 4:11pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/1 "2025-12-24T16:11:05Z")

</div>

Perspective 8.1.47

I am trying to create a new datakey to use in a report that is one day prior to the t\_stamp from another tag historian query data source. I tried following the manual, but am getting some errors and the manual doesn’t have the exact case I am looking for. I’m pretty sure I’m using the dateArithmetic function incorrectly. I hope I pasted the code correctly. If I remove the dateArithmetic function from line 13 (it overflows in this pasted code to the next line), then the FlowsLogDate data source is created with the FlowsLogDate datakey. How should I format this to do the date math on the source data? Thank you! Also, the data source tag historian query is wide return format if that matters.

```python
def updateData(data, sample):
	#data['myKey']='Example'
	
	#build a header and initialize a pydataset
	header = ['FlowsLogDate']
	filteredDataset = []
	
	#get the results form the FLOWS data source
	rawDataset = data['FLOWS'].getCoreResults()
	
	#build the new pydataset out of only some of the FLOWS data keys
	for row in range(rawDataset.rowCount):
		valFlowsLogDate = dateArithmetic(rawDataset.getValueAt(row,'t_stamp'),-1,"day")
		filteredDataset.append([valFlowsLogDate])
	
	#convert the pydataset to a standard dataset
	filteredDataset = system.dataset.toDataSet(header, filteredDataset)
	
	#create a new data source with the filtered results
	data['FlowsLogDate'] = filteredDataset

```

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 4:14pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/2 "2025-12-24T16:14:05Z")

</div>

Sorry, should have also reported that the Data Collection Errors warn message is: Error invoking script.Traceback (most recent call last): File “\<function:updateData.” line 13 in updateDataNameError: global name ‘dateArithmetic’ is not defined.

And a slider bar appears on the published post where line 13 does not overflow to the next line.

---

<div class="post-metadata">

**Author:** ![tgarrison](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tgarrison/32/80965_2.png) [@tgarrison](https://forum.inductiveautomation.com/u/tgarrison)\
**Post date:** [December 24, 2025, 4:30pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/3 "2025-12-24T16:30:13Z")

</div>

You're in python scripting. system.date.addDays() is what you're going to want.

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 4:47pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/4 "2025-12-24T16:47:56Z")

</div>

Thank you @tgarrison, that fixed the error. Do you know how I get this script to work for all rows? It now just returns the same date for all rows of my report.

If I “show calculations” in the key browser and select datakey “count” for the FlowsLogData source, it does give the correct count of rows.

---

<div class="post-metadata">

**Author:** ![tgarrison](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tgarrison/32/80965_2.png) [@tgarrison](https://forum.inductiveautomation.com/u/tgarrison)\
**Post date:** [December 24, 2025, 4:53pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/5 "2025-12-24T16:53:20Z")

</div>

Are you sure your t\_stamp column has varying dates?

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 4:56pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/6 "2025-12-24T16:56:20Z")

</div>

Yes, if I put t\_stamp back in the report details cell, it populates sequential dates (one day off) for each row.

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 4:57pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/7 "2025-12-24T16:57:45Z")

</div>

It’s encouraging that it is the first date I would expect, each row is just not incremented by one calendar day.

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 5:10pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/8 "2025-12-24T17:10:20Z")

</div>

Nevermind, if I create a new table by dragging the new data source onto my report from the Key Browser, and drop datakey ‘FlowsLogDate’ onto a cell in the Details row, it populates the dates I would expect. I just need to figure out how to relate the data into my existing object. Or reformat my report with an added table component. Sigh, I don’t like the interface to manipulate report objects on the designer.

---

<div class="post-metadata">

**Author:** ![tgarrison](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tgarrison/32/80965_2.png) [@tgarrison](https://forum.inductiveautomation.com/u/tgarrison)\
**Post date:** [December 24, 2025, 5:13pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/9 "2025-12-24T17:13:19Z")

</div>

Odd. Your script looks like it should be good. Maybe step it thru (remove the date math and see if the .get(row,t\_stamp) does return the sequential dates..) Then go from there. Or add the row number to your output dataset so you can verify it's actually incrementing the row number.

---

<div class="post-metadata">

**Author:** ![bpomerhn](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@bpomerhn](https://forum.inductiveautomation.com/u/bpomerhn)\
**Post date:** [December 24, 2025, 5:22pm UTC](https://forum.inductiveautomation.com/t/report-script-data-source-help/112986/10 "2025-12-24T17:22:10Z")

</div>

I tried adding the the data source to the table and that didn’t seem to correct it. Instead, I just deleted the datakey out of the existing problem cell for t\_stamp, and drug the new data source onto the report to create a table, formatted details row to be one column wide with same dimensions as the problem cell in the other component and it works perfectly. Thanks again for the help!
