system.dataset.filterColumns

Hi all,
I want to filter my dataset by using a dropdown list in a binding script
the problem is when get the value from my dropdown list and I do the filter on the dataset it gave me an error

the dataset :
image

dataset = self.parent.custom.chart_L_sup_p1
nb = 2,self.custom.key
value = system.dataset.filterColumns(dataset, nb)
return value

What is it ?

And why is the nb = 2, self.custom.key line appearing like a link in the snippet ?
edit: I'm thinking you initially surrounded 2, self.custom.key with parenthesis and used a quote block instead of a code block, which made it interpret it like if it was markdown...
Use code blocks instead.

Please use the </> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the πŸ–‰ edit link to fix your post.

Same question as @pascal.fragnoud, but according to the docs, the 'columns' param is a List of either string or int.

The line given is a Tuple:
nb = 2, self.custom.key

For it to be a List, it should be declared with brackets:
nb = [2, self.custom.key]

Assuming the filterColumns method doesn't covert from Tuple to List, this could be your issue.
Hope this helps.

It does work with tuples.
image

I also noticed your edit where OP may have used parenthesis in the declaration, making the nb variable a set, correct? Does the filterOptions method also take in sets?

Parentheses make tuples, sets are made with curly brackets:

this_is_a_tuple = (1, 2, 3)
this_is_a_set = {1, 2, 3}

edit: Unless there's nothing inside the brackets, in which case it makes an empty dict.

I suspect you will be disappointed. This:

nb = 2,self.custom.key
value = system.dataset.filterColumns(dataset, nb)

suggests to me that you want the row where column 2 matches the given key value. That's not what filterColumns does.

If so, see this topic, but reverse its sense: