General Caster Formula Utilizing Dropdown

Is there a way to use a General Caster formula to populate a number in a number column when a specific option is selected from a dropdown?

Ex. My dropdown includes Red, Orange, Yellow. Someone selects yellow, I want it to place a “1” in my number column that is labeled yellow.

Help!

While I’m not sure how to do it in General Caster, with the app Formula PRO, you can achieve your result using the following formula:

IF(IFERROR(SEARCH('yellow', {item's Dropdown}), 0) > 0, 1, 0)

How does the formula work:

  1. {item's Dropdown} evaluates to a string in the form <id>:<dropdown_value> example: 3:yellow
  2. SEARCH("yellow", "3:yellow"): Searches for "yellow" in the provided string. Returns the starting position of the substring if found. Throws an error if the substring is not found.
  3. IFERROR(..., 0): Catches the error thrown by SEARCH when "yellow" is not found. Returns 0 instead of throwing an error.
  4. IF(... > 0, 1, 0): Checks if the position returned by SEARCH is greater than 0 (indicating that "yellow" was found). Returns 1 if "yellow" exists; otherwise, it returns 0.

Let me know if that works for you.

Disclaimer:
I’m one of the developers of Formula PRO.

:rocket: Formula PRO: Advanced Automations for native monday formula columns, Mirror Columns & Subitems!