# Calling values from Tag\_calc & Tag\_history query into script

**URL:** <https://forum.inductiveautomation.com/t/calling-values-from-tag-calc-tag-history-query-into-script/103567>\
**Category:** Ignition\
**Tags:** scripting, ignition81, reporting\
**Created:** [March 12, 2025, 10:22am UTC](https://forum.inductiveautomation.com/t/calling-values-from-tag-calc-tag-history-query-into-script/103567 "2025-03-12T10:22:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![milton.stathakis](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/milton.stathakis/32/73561_2.png) [@milton.stathakis](https://forum.inductiveautomation.com/u/milton.stathakis)\
**Post date:** [March 12, 2025, 10:22am UTC](https://forum.inductiveautomation.com/t/calling-values-from-tag-calc-tag-history-query-into-script/103567/1 "2025-03-12T10:22:30Z")

</div>

Hi everyone,

In my report, I have set up a tag calculation query data source 'Calc\_Cold' that gets basic average, min, max, stddev for one specific tag. I have another data source that is a tag history query, this retrieves the LSL and USL values with a 'closest value' aggregation mode. Both queries have the same dynamic start and end range.

I am trying to write a script data source that returns two data keys 'Cp' and 'CpK'. How can I retrieve the avg, stddev, LSL and USL values from these data sources and do my calculations in the script?

Thank you

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 12, 2025, 11:04am UTC](https://forum.inductiveautomation.com/t/calling-values-from-tag-calc-tag-history-query-into-script/103567/2 "2025-03-12T11:04:32Z")

</div>

You can access the data from data sources above the script data source in the data sources list via the `data` map.

```python
calcCold = data['Calc_Cold']

```

You can read about that in the manual:

> **[Scripting Data Source | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/reporting/report-data/scripting-data-source)**
>
> The Script data source allows you to use scripting to add data into a report, or modify existing data. With this data source, you can pull in data from the database and then modify it using a script before pushing it out as a data key for use in the...
