# How to manage the table component of a report when column number can change at runtime

**URL:** <https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 23, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383 "2021-11-23T14:02:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [November 23, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/1 "2021-11-23T14:02:29Z")

</div>

Hi folks, I have this controversial question that I can’t solve.  
In my project, I show the table with a number of columns that can change during the runtime operation.  
The operator has to print this information at runtime and I have made a report showing all the information  
using table and graph. What is the smarter way to manage the table in my report to dynamically fit the table as the number of columns in the dataset that I pass to it changes? I don’t think many develop  
report is the smartest solution, but I can’t figure out what to do on my report to make it dynamic in this situation!

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 23, 2021, 2:22pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/2 "2021-11-23T14:22:56Z")

</div>

[https://docs.inductiveautomation.com/display/DOC81/Report+-+Simple+Table](https://docs.inductiveautomation.com/display/DOC81/Report+-+Simple+Table)  
maybe idk i’ve not realy done alot with reports yet

---

<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:** [November 23, 2021, 2:56pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/3 "2021-11-23T14:56:48Z")

</div>

This approach is probably the best you can do:

> [@Dynamic Table in Reporting](https://forum.inductiveautomation.com/t/dynamic-table-in-reporting/21397/9):
>
> If the formatting difference you’re looking for is the number of rows/columns in the table, and the names on the columns, this can be done, but it is a big of a slog. Here’s how I did it: In my report, I have a table with the most columns I expect I could ever need (7 in my case). That table looks for column names like ‘A’, ‘B’, ‘C’, ‘D’ in the dataset it is pulling from. Some layout features of the cells like hidden and width are bound to custom report data named like ‘COL\_x\_HIDDEN’ and ‘CO…

TL/DR:

Reporting tables cannot have variable numbers or columns, nor variable column names. You can fake it to a certain extent by hiding columns and using other variables for the column names in the table header. Consider using a script data source to transform any given dataset to have the needed column names while populating the variables for the column headers from that given dataset. And hiding the unused columns.

Good luck.

---

<div class="post-metadata">

**Author:** ![dkeith](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dkeith](https://forum.inductiveautomation.com/u/dkeith)\
**Post date:** [February 2, 2022, 11:22pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/4 "2022-02-02T23:22:09Z")

</div>

I’ve created a report with a dynamic number of columns using a .csv layout. The report script uses system.tag.queryTagHistory and the list of tags to report is a parameter passed to the report and therefore of unknown size.  
The results dataset goes through system.dataset.toCSV to get a csv string. Then an extra

csv = csv[1:-2]

to remove the leading/trailing " marks.  
The report table is a single column that holds the resulting dataset.

The preview looks ugly and I doubt it works as a vision component, but sending by email as a file attachment works just fine.

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [April 4, 2024, 9:02pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/5 "2024-04-04T21:02:36Z")

</div>

Bump. I have a dataset in a table that changes depending on a site location. I want to use this dataset (which i manipulated using scripts) and spit out a report that is identical. It looks like I have to have the dataset in the report then set the columns using that. Has there been an improvement to allow for dynamic columns? I basically want to print the table with some report formatting (Title, page number, company logo, etc).

---

<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 4, 2024, 9:07pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/6 "2024-04-04T21:07:58Z")

</div>

No change. You have to have a report table with the maximum possible columns, and use a script to massage your supplied data to accommodate that table's needs. As described in the link above.

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [April 5, 2024, 12:45pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/7 "2024-04-05T12:45:49Z")

</div>

Might be a dumb question. On the report, when dropped in a view, how do I edit the visibility from scripting? I can only do it by selecting the checkbox when working on the report.

---

<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 5, 2024, 1:05pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/8 "2024-04-05T13:05:44Z")

</div>

Bind a data key to it.

---

<div class="post-metadata">

**Author:** ![Ujwal\_Wankhede](https://avatars.discourse-cdn.com/v4/letter/u/4af34b/32.png) [@Ujwal\_Wankhede](https://forum.inductiveautomation.com/u/Ujwal_Wankhede)\
**Post date:** [April 5, 2024, 1:56pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/9 "2024-04-05T13:56:40Z")

</div>

Try using CrossTab. I've implemented it in a report where the number of weekdays in production changes(Columns). It shows production for each day per hour, even hours are also dynamic(Rows).  
[Ignition manual reference](https://docs.inductiveautomation.com/docs/8.1/appendix/components/report-design-components/report-design-table-palette/report-component-crosstab-table)

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [April 5, 2024, 6:23pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/11 "2024-04-05T18:23:35Z")

</div>

Perfect. I reformatted my data and got it working!

Data in table (Historian Query:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/1/e1d3e88fa49999c0d1a80eef8232eecb2d027721.png)

Did a transform to reformat the data:

```auto
def transform(self, value, quality, timestamp):
	header = ["Sensor", "Time", "Value"]
	data = self.custom.db_datacorrected
	newData = []
	sensor = ""
	time = ""
	value = ""
	
	#Format data in Sensor, Time, Value
	for row in range(data.rowCount):
		time = data.getValueAt(row,0) #Grab time info
		for col in range(data.columnCount):
	   		if col != 0:
	   			sensor = data.getColumnName(col) #Grab sensor info			      
				value = data.getValueAt(row, col) #Grab value of sensor
			      
				newData.append([sensor,time,value])
	      
	
	dataset = system.dataset.toDataSet(header,newData)
	sortedDataSet = system.dataset.sort(dataset, "Sensor")
	pyData = system.dataset.toPyDataSet(sortedDataSet)
	return pyData

```

Report:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43c334ca4025f8cb49e20cce9f56a026381853e3.png)

---

<div class="post-metadata">

**Author:** ![mldrouil](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mldrouil](https://forum.inductiveautomation.com/u/mldrouil)\
**Post date:** [April 29, 2024, 8:47pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/12 "2024-04-29T20:47:52Z")

</div>

Thanks for these ideas folks! I was able to get the cross tab working well but it always seems to make the font go really tiny as more columns are added?? I can bind the font size to update to be larger for each column added but that is not exactly elegant to say the least.

I have reduced cell margins, bound width and height values, overflow is grow row..... I really don't understand how this text shrinkage is "default"

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2b4c7feff17004d26d2060c57e0e195b4ed0ee0.png)

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [May 14, 2024, 4:17pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/13 "2024-05-14T16:17:26Z")

</div>

Update your column info. Should be able to adjust settings there!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/e/6e60ad498bf41e4691c055eaf63a32cb700b2f4b.png)

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [May 14, 2024, 4:18pm UTC](https://forum.inductiveautomation.com/t/how-to-manage-the-table-component-of-a-report-when-column-number-can-change-at-runtime/53383/14 "2024-05-14T16:18:14Z")

</div>

What settings do you have set?
