Jul 25, 2023 11:20 AM
Hello!
I am trying to create if statements to categorize products. For example: if the product id is 02568, it will be category a; if its 12487 it will be category b; if 25777 it will be category c, an so forth. However, each product id number is not the same. So, category A would have serial numbers like 03577 as well as 06554 and so forth. Each category starts with the same first number. First problem is trying to identify in airtable only the first number to categorize. I tried doing this:
Jul 25, 2023 11:32 AM
If Product ID # can be changed to a Single Line Text that will solve the issue with dropping the leading 0.
Then if({Product ID #}=0...) can become if(LEFT({PRODUCT ID #}, 1)="0"...)
Jul 25, 2023 11:41 AM
Is there a way to extract just one number from a string of numbers without doing it manually?
Jul 25, 2023 12:24 PM
I don't understand the question, or at least the specifics of it.
What I suggested would return the first character in the string.
If you're looking for the character at a specific position I would use a combination a of LEFT() and RIGHT() - RIGHT(LEFT({field name}, 4),1) should give you the character in the 4th position, but if 10 people respond they could probably give you 10 different variations.
FIND() and SEARCH() can tell you if a specific character occurs in a string, and SEARCH() returns the location.
Jul 25, 2023 04:38 PM
For example, this formula could be.
In this formula, the product ID needs to be String field.
SWITCH(LEFT({Product ID #},1),
"0", "A",
"1", "B",
"2", "C",
BLANK()
)
Jul 26, 2023 11:03 AM
What is the point of having the Blank() in here?
Jul 26, 2023 04:52 PM
SWITCH(expression, [pattern, result ... , default])
The last argument is an optional default value that is not necessarily needed.
For example, you could put an error message here.