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

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!

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

This approach is probably the best you can do:

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.

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.

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).

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.

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.

Bind a data key to it.

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

1 Like

Perfect. I reformatted my data and got it working!

Data in table (Historian Query:
image

Did a transform to reformat the data:

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:

1 Like