# How to pass a dataset from a window to a report?

**URL:** <https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 2, 2021, 9:03am UTC](https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343 "2021-06-02T09:03:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elijah.puga](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/elijah.puga/32/23091_2.png) [@elijah.puga](https://forum.inductiveautomation.com/u/elijah.puga)\
**Post date:** [June 2, 2021, 9:03am UTC](https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343/1 "2021-06-02T09:03:11Z")

</div>

I have a dataset on my window and I want to pass that dataset to a report parameter. Upon searching the forum I found this post: [Generating a report from window components - #6 by ethomason](http://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/6)

I tried to create a parameter (Parameter type is dataset). I just replicated step 1 and step 2 from the post:

![New Parameter](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37696c4de894e96f72a9792558fd09b69fc892cf.png)

 ![Data Sources](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/2/c230ae64e7b9a29252388fdf269c5ffdf1606acf.png)

I got an error:  
WARN: Parameter “KWHdataset” missing default value expression.

WARN: Error invoking script.Traceback (most recent call last):  
File “function:updateData”, line 3, in updateData  
KeyError: KHWdataset

How am I suppose to do this? Is there a better way to do this?

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 2, 2021, 10:14am UTC](https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343/2 "2021-06-02T10:14:01Z")

</div>

If the dataset already exists on the window and is being passed to the report, you don’t need the Script datasource in the report. To get a default dataset in KWHdataset, add something like the following to the Default Value (expression) box when KWHdataset is selected… Commas, quotes, brackets, etc. all matter, start with something very simple, then expand to look like the expected dataset.

```auto
runScript('system.dataset.toDataSet(' +
    '["header_1", "header_2"]' +
    ',[' +
    ' [row_1_col_1, row_1_col_2],'
    ' [row_2_col_1, row_2_col_2],'
    '])')

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 2, 2021, 3:22pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343/3 "2021-06-02T15:22:44Z")

</div>

Another option is to make a dataset tag with the structure of your final data - you can then use that as sample data while building your report.

---

<div class="post-metadata">

**Author:** ![elijah.puga](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/elijah.puga/32/23091_2.png) [@elijah.puga](https://forum.inductiveautomation.com/u/elijah.puga)\
**Post date:** [June 3, 2021, 12:51am UTC](https://forum.inductiveautomation.com/t/how-to-pass-a-dataset-from-a-window-to-a-report/47343/4 "2021-06-03T00:51:20Z")

</div>

This works for me. A few corrections on your sample code:

```auto
runScript('system.dataset.toDataSet(' +
    '["header_1", "header_2"]' +
    ',[' +
    ' ["row_1_col_1", "row_1_col_2"],' +
    ' ["row_2_col_1", "row_2_col_2"],' +
    '])')

```
