Dataset getValueAt Row Where Column Equals

Is there a way to get the value at a cell if I know the value of another cell in one specific column, but maybe not what the row index is?

For instance, I have one column “name” that is 0, 1, 2, 10, 3, 5. I want to get the “status” column for the row where the “name” is 10.

The lookup() expression function.

Ok, I can make a custom property with that expression and access via the script, but I’m doing this in a script anyway, so is there a nice way to do it in scripting too? Or is that the cleanest way?

edit: that doesn’t actually work because the dataset is the tabData property of a tabStrip which I cannot access when creating an expression binding

That surprises me. If you must, move the tab data to a custom prop where your expression can get it, and use a property binding to drive it into the actual tab strip.

1 Like

In a script, use list(ds.getColumnAsList(...)) on the column of match values then use the .index() method to find the row index.

This will likely end up being the solution. The custom property with a copy of the dataset kind of worked, but the property that is bound to the copy of the dataset doesn’t actually update fast enough so the script was executing with the old value that was still in there

Final solution:

	#get the value using the provided selected index
	columnIndex = tabData.getColumnIndex("NAME")
	columnList = [ int(val) for val in tabData.getColumnAsList(columnIndex)]
	rowIndex = columnList.index(selected_index)
	value = tabData.getValueAt(rowIndex, "val")