Verify if a liste of value is on a dataset column

Hello, I have a dataset with a column colled id_Zone.
On my parameters I have listZone that have a listZone = 1,3

If my listZone is on dataset (column id_Zone), checkbox is True

image

I would recommend using an expression structure binding, using both view.params.listZone and view.params.listZoneBuilding. You can then use a script transform to check if one is in the other.

Expression Structure Bindings in Perspective - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

Script Transform - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

1 Like

Your expression is on a boolean checkbox?
You're attempting to evaluate if an integer called list zone exists in the id_zone column?

1 Like

convert the dataset column id_Zone into a list by,

TIP - Converting a dataset column into a list - Ignition - Inductive Automation Forum

compare if it is present in the listZone by,

any(map(lambda value: value in id_Zone, listZone ))

1 Like

Thank you. here is the solution I have.
image

Don't post screenshots of code, post the code directly, surrounded in triple backticks:

```python
code
```

Here's how to rewrite your script more pythonically using @vasanth.p 's method:

listZoneBuilding = value['listBuildingZone']
listZone = value['listZone']
zoneIds = listZoneBuilding.getColumnAsList(x) # replace x with the column's index.
return any(map(lambda zone_id: zone_id in zoneIds, listZone))
1 Like

As @pascal.fragnoud has shown there is a better way to write the transform. Also, there is a generic way to get the index from the column name.

listZoneBuilding = value['listBuildingZone']
listZone = value['listZone']

zoneIds = listZoneBuilding.getColumnAsList(listZoneBuilding.getColumnIndex('id_zone'))
return any(map(lambda zone_id: zone_id in zoneIds, listZone))
1 Like

I think listZone is supposed to be a list of ids, zone so you can't check it like that. That's why @vasanth.p suggested using map.

2 Likes

Huh, some how I missed that.