Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am not sure the right syntax for using OR within the IF function with variable:
For example, I have a variable, vFood, which could be: 'apple', 'orange', 'beef', 'chicken', ….
Now I want to define a new variable, vFood_type, which will show 'fruit', 'meat', 'other'
IF('$(vFood)'='apple' OR 'orange', 'fruit', IF('$(vFood)'='beef' OR 'chicken', 'other'))
The result was that only the first parameter was evaluated, and when vFood = 'orange' or 'chicken', it gives 'other'.
Any advice ? I can use multiple IF function to replace OR, but it would take me 10+ IF loops in my real case
Thanks.
Try this.
=Pick(Match($(vFood),'apple', 'orange', 'beef', 'chicken')+1,'other','fruit','fruit','meat','meat')
apple = fruit
beef = meat
milk = other
Try this.
=Pick(Match($(vFood),'apple', 'orange', 'beef', 'chicken')+1,'other','fruit','fruit','meat','meat')
apple = fruit
beef = meat
milk = other
Thanks a lot for your prompt advice and especially on Sunday. May I also know the usage of +1 in your example ?
By +1, I push OTHERWISE to the first place ('other'). For 'milk' the value will be 'other'.
Great! You are very helpful.
Thanks a lot.
you welcome