Report Filter Key Help

I have a report that I would like to filter the rows that are displayed based on a column called ID that can have a value of 1-6. I would like to use a drop down menu to accomplish this but have not been able to get it working using the filter key on the reports table. If someone could give me an example on what is required to achieve this I would appreciate it.

I looked into this - and it’s a mixed bag.

Good news: This is possible.
Bad news: It’s not as easy as it should be. It is a known bug - but I can’t promise when it will be fixed.

Basically - the table filter key property only ‘knows’ about keys within the datasource used in the table. So, in order to use a report parameter as a table filter key, you need to add a new column to your query result to compare against. So here’s some sample code that does that:

	#get the results of the current 'query' datasource (getCoreResults returns a standard Dataset)
	dataset = data['query'].getCoreResults()
	
	#create a new datasource, and set it to a new dataset: the original dataset with one additional column
	#wrapped to multiple lines to help documentation
	data['newQuery'] = system.dataset.addColumn(dataset,
		#set the index of the new column to be the 'last' column; this takes advantage of 1 vs 0 indexing
		dataset.columnCount,
		#repeat the 'IDParameter' property once for every row in the original query results; this is necessary because datasets have to be perfect 2D arrays
		[data['IDParameter']] * dataset.rowCount,
		#set the name of the new column (the key that it will be referred to in the design tab)
		'IDFilter',
		#set the datatype of the new column
		long)

Make sure to change the ‘query’ and ‘IDParameter’ strings in the code to the actual names you’re using in your report. Within the report, you should get a new datasource with an additional key (‘IDFilter’, if you didn’t change it) added. You can then use this in your table (see attached).

Now, to actually filter this within a Vision window, you’ll just have to bind the ‘IDParameter’ (or whatever you named it) property of your Report Viewer component to the value of your dropdown component.

1 Like