Extracting data from datasets


just wondering if anyone could help me with the datasets. currently i have got a dataset created in tag and i want to extract the column names from the tag according to the conditions given. Here in this case in the first picture i have uploaded, a condition table can be seen , for eg in the second picture i have uploaded, that is the operator entry form. what i am looking to do is that if the operator selects 'Pin Holes' under the 'result' bay then 'anode' and 'control' should be displayed which means whatever checkbox is being selected (picture 1) the 'defect area' bay should return only the output only which are being selected. 'defect area' (picture 2) is a dropdown option.

Sounds like an expression lookup function might suit your needs.

https://docs.inductiveautomation.com/display/DOC81/lookup

Pass in your defect_types tag as the dataset to look up.

1 Like

i have tried using lookup function, but still it is showing some error, I couldn't get the required result.

...so the user selects something from the result dropdown, and the defect area dropdown populates with header names of whatever columns are checked for that given row? In this case, it would be 'New Defect'?

This seems like it would be simpler to script from the dropdown's property change event handler. Here is an example that would work for your usage case:

#Run this from your result dropdown's propertyChange event handler
if event.propertyName == "selectedLabel":
	tagValues = system.tag.readBlocking(['[default]myTagPath/datasetTag.value'])#Make this your tag path
	dataset = tagValues[0].value
	headers = ["Value", "Label"]
	rows = []
	for column in range(1, dataset.columnCount):#skip the string column (That would always be true)
		if dataset.getValueAt(event.source.selectedIndex, column):
			rows.append([len(rows), dataset.getColumnName(column)])
	event.source.parent.getComponent('DefectArea').data = system.dataset.toDataSet(headers, rows)#Change the component path to match your defect area dropdown component path
1 Like

This works perfectly . Thank you so much for your help. Really appreciate it.

1 Like