Forum Discussion
Marjia
1 year agoFrequent Visitor
Functions for conditions having multiple values
Hello, What could be used intead of Switch/If function when the result of each condition is not scalar? Thanks in advance!
OwenAuger
Super User
1 year agoA general structure you can use to return a conditional table is:
UNION (
FILTER (
<TableExpression_1>,
<Condition1>
),
FILTER (
<TableExpression_2>,
<Condition2>
),
...
)
The conditions <Condition1> etc should be constants within FILTER, and might be evaluated up-front and assigned to variables.
All of the table expressions would naturally have to have the same number of columns. If the columns of the table expressions have different lineage, you may need to apply TREATAS to enforce lineage (if required).