I've just found about the very handy use of boolean logic to shorten/replace multiple Nested If Statement from this question (4th answer):
Is there a way to shorten multiple if statements?
With this given example as substitute for multiple nested IF statements:
Multiple Nested IF Statements version:
= IF(E3 = "red", 100, IF(E3 = "blue", 200, IF(E3 = "green", 300, IF(E3 = "orange", 400, 500))))
Vs
Boolean Logic version:
= (E3 = "red") * 100 + (E3 = "blue") * 200 + (E3 = "green") * 300 + (E3 = "orange") * 400 + (E3 = "purple") * 500
That works well when returning a number is intended.
If true, the following returns 100 or 200.
=(REGEXMATCH(B19,F2)) * 100 + (REGEXMATCH(B19,F40)) * 200
But I get MULTIPLY or ADD errors when trying to return strings.
For example, with the 2 strings "Time" in cell F2 and "Test" in cell F40:
=(REGEXMATCH(B19,F2)) * F2 + (REGEXMATCH(B19,F40)) * F40
returns this error:
Function MULTIPLY parameter 2 expects number values. But 'Test' is a text and cannot be coerced to a number.
=(REGEXMATCH(B19,F2)) & F2 + (REGEXMATCH(B19,F40)) & F40
returns this error:
Function ADD parameter 1 expects number values. But 'Test' is a text and cannot be coerced to a number.
=(REGEXMATCH(B19,F2)) & F2 & (REGEXMATCH(B19,F40)) & F40
returns:
FALSETimeTRUETest
My question:
Is there a way to use Boolean logic with strings? If possible as concise as the way with numbers?
What operator is available for strings if there are some?
Many thanks for your help and insights!