# Report with Script Datasource that takes a long time to run

**URL:** <https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [April 7, 2025, 10:45pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803 "2025-04-07T22:45:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![downerczx](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/downerczx/32/11649_2.png) [@downerczx](https://forum.inductiveautomation.com/u/downerczx)\
**Post date:** [April 7, 2025, 10:45pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803/1 "2025-04-07T22:45:20Z")

</div>

I have a report with a script datasource. The script can take up to 15 minutes to run. It times out the reporting engine. Is there a way to let the report module just let the script finish before panicking and abandoning ship? Or, do I have to write my dataset to a tag somewhere and run the script ahead of running the report somehow. I would rather let it run on demand.

---

<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:** [April 7, 2025, 10:47pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803/2 "2025-04-07T22:47:41Z")

</div>

Perhaps analyze the script to find out why it takes so long?

---

<div class="post-metadata">

**Author:** ![downerczx](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/downerczx/32/11649_2.png) [@downerczx](https://forum.inductiveautomation.com/u/downerczx)\
**Post date:** [April 7, 2025, 10:50pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803/3 "2025-04-07T22:50:24Z")

</div>

I don't know a way around it. For every hour, get a time weighted average of the last 24 hours (relative to that hour). Get 30 days worth of this. So, 30x24 or 720 hours. Also get a time weighted average of the last 60 days for every hour (relative to that hour). Format will be like [t\_stamp, hour24avg, hour60dayAvg]. It just takes a long time to run.

---

<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:** [April 7, 2025, 10:54pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803/4 "2025-04-07T22:54:51Z")

</div>

Every hour, a little bit after the hour, compute that hour's averages and save them to a DB table. Then your report query only has to do the hourly time weighting. Should take a few dozen milliseconds.

---

<div class="post-metadata">

**Author:** ![downerczx](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/downerczx/32/11649_2.png) [@downerczx](https://forum.inductiveautomation.com/u/downerczx)\
**Post date:** [April 9, 2025, 4:39pm UTC](https://forum.inductiveautomation.com/t/report-with-script-datasource-that-takes-a-long-time-to-run/104803/5 "2025-04-09T16:39:03Z")

</div>

Thanks, Yes that would work. I finally figured out I can offload my calcs to a script I can execute and put in memory dataset before running report on memory dataset instead.
