Forum Discussion
ERROR() triggered in SWITCH() Function for no reason
- 4 years ago
Hi JoachimSA
You can use if() function instead of switch().
Because, for Switch() function, all result expressions and the else expression must be of the same data type.
for IF() function, it can return a variant data type if value_if_true and value_if_false are of different data types, but the function attempts to return a single data type if both value_if_true and value_if_false are of numeric data types. In the latter case, the IF function will implicitly convert data types to accommodate both values.
The error() function will give the specific error prompt and stop the calculation when the conditions are met.
The reason is the expression should not return processed values when encountering specific errors, these values are incorrect, it should generate invalid reports instead of unreliable numbers that may be considered correct. Also, that will lead to unnecessary resources waste.
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
HI JoachimSA ,
The syntax should be
Result = SWITCH(
TRUE(),
Condition 1, Result1,
Condition 2, Result2,
"Error"
)
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)