How can I count the number of choices in a choice list field?

I created a table that allows me to filter for different criteria and see what affect it has on summary results.

I have an AutoRemove field that has a series of OR statements that determine if a record gets included in the summary calculations. There is an AutoRemove table that feeds the AutoRemove column to decide if a criteria gets included

Each individual statement is an AND of the bool for if the criteria is included along with whatever the criteria would be.

For example, the top AND statement below is where I want to remove records that contain ‘DD’ in the Setup column.

But I would like to keep the record if there is another Choice in the Choice List field. In this example, I want to remove all the records that contain ONLY ‘DD’ in the Setup field. But I want to keep the records that have other entries in the Setup field which is Choice List field

I tried using ‘not’, but it didn’t work and would take a ‘not’ statement for each choice which seems inefficient.

If I could count the number of choices in the Setup field, I could check to see if there is more than 1. But I don’t know how to check that or what the python code would be in my example.

I don’t know if there is another way to check for a single entry in a choice list field

any help is appreciated


AutoRemove.lookupOne().RemoveDD == True,
any('DD' in value for value in $Setup),
any('DC' not in value for value in $Setup)

AutoRemove.lookupOne().RemoveDC == True,
any('DC' in value for value in $Setup),

AutoRemove.lookupOne().RemoveDE == True,
any('DE' in value for value in $Setup)

Hi there!

You can use len() to count the number of items in a list and then check if the specific value is in the list. The formula I used in the screenshot below is:

if len($Setup) == 1 and "DD" in $Setup:
  return None
  return $Setup

Hope this helps!


1 Like