# Ignition reporting module - dynamic SQL query

**URL:** <https://forum.inductiveautomation.com/t/ignition-reporting-module-dynamic-sql-query/70881>\
**Category:** Ignition\
**Created:** [March 10, 2023, 5:13am UTC](https://forum.inductiveautomation.com/t/ignition-reporting-module-dynamic-sql-query/70881 "2023-03-10T05:13:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.eichler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/john.eichler/32/24632_2.png) [@john.eichler](https://forum.inductiveautomation.com/u/john.eichler)\
**Post date:** [March 10, 2023, 5:13am UTC](https://forum.inductiveautomation.com/t/ignition-reporting-module-dynamic-sql-query/70881/1 "2023-03-10T05:13:36Z")

</div>

Ignition 8.1.23

I have a table with a series of measurements at different dates. This is in wide format with a "row" for each date and "columns" for each measurement. This data is inserted into SQL by parsing a text file created by a CNC machine. It is not tag historian data.

I have written a simple script that queries the SQL table and returns a dataset. The dataset is set up as a parameter in the report and I can plot it on a time series chart. However, to do so, I have to manually type in the range key names. This will not work as a solution because the name of each measurement is dynamic as is the number of measurements.

Essentially, I have a dataset input with variable number of keys and variable key names.

Please can someone suggest a better way to achieve my desired result?

Cheers

---

<div class="post-metadata">

**Author:** ![bas\_bekker](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bas\_bekker](https://forum.inductiveautomation.com/u/bas_bekker)\
**Post date:** [March 11, 2025, 2:54pm UTC](https://forum.inductiveautomation.com/t/ignition-reporting-module-dynamic-sql-query/70881/2 "2025-03-11T14:54:47Z")

</div>

I have the exact same issue. Does anyone have a solution?

---

<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:** [March 11, 2025, 3:02pm UTC](https://forum.inductiveautomation.com/t/ignition-reporting-module-dynamic-sql-query/70881/3 "2025-03-11T15:02:06Z")

</div>

Reporting can't do variable numbers of keys or names of keys. However, it can **hide** unwanted table columns or chart pens, and use alternate labels for any particular key. The general solution is to create the report using a generic keys, like `t_stamp`, `col1`, `col2`, ... , `col16`. Then use a script data source to produce a datasource to supply the desired labels for `col1`.... and to run a custom query that yields the generic columns names in the output.

(Yes, this is a bit tedious, and you have to know the maximum number of possible columns ahead of time.)
