15 Replies Latest reply: Jan 18, 2017 11:13 PM by bhawana adhikari

# How to create a flag with two conditions?

Hi all,

I have a requirement with two conditions

1) If(DSI<14 and open orders=0 and match(report metric key,5),1,0)

2) if(open orders=0 and match(report metric key,1,2,3,4,5,6,7),1,0)

How can I combine these two if condition in data load editor and create a flag ??

Thanks

Juna

• ###### Re: How to create a flag with two conditions?

if((DSI<14 and open orders=0 and match(report metric key,5) OR (open orders=0 and match(report metric key,1,2,3,4,5,6,7),1,0)

• ###### Re: How to create a flag with two conditions?

Can be simplified as below,

if(open orders=0 , if( (DSI<14 and match(report metric key,5)) OR (match(report metric key,1,2,3,4,5,6,7)),1,0),0) as FLAG

• ###### Re: How to create a flag with two conditions?

Hi,

Thank you Vineeth. Second expression looks fine.  I see  four dummy values 99991,99992,99993 and 99994 in DSI after using your second expression. How can I remove these values from the same expression?

Also I can see both  <14 DSI  and > 14 DSI values for report metric key 5 after using your expression. How can we fix it

Thanks

Juna

• ###### Re: How to create a flag with two conditions?

That is because of your second condition you want all report metrics keys from 1 to 7

Can you confirm exactly what you need?

If the DSI < 14 is only applicable to metric 5, then remove 5 from the 2nd condition

if(open orders=0 , if( (DSI<14 and match(report metric key,5)) OR (match(report metric key,1,2,3,4,6,7)),1,0),0) as FLAG

• ###### Re: How to create a flag with two conditions?

Hi Vineeth,

I kept report metric key only 2 in second expression. Also removed  1 and 4 from first condition.

Still in table I see values >14 and <14  for DSI.

if(Open orders=0 , if( (DSI<14 and match(report metric key,5))

OR (match(report metric key,2)),1,0),0) as DSI_Open_Orders,

Thanks

Juna

• ###### Re: How to create a flag with two conditions?

what is the metric key for those values >14 ?

• ###### Re: How to create a flag with two conditions?

Its 4 and 5...Everything else is fine in table now...Just need to remove values > 14 for DSI for report metric key 5.

• ###### Re: How to create a flag with two conditions?

is Open orders=0 for those records?

• ###### Re: How to create a flag with two conditions?

Thank u Vineeth....It works absolutely fine now

• ###### Re: How to create a flag with two conditions?

Can you close the discussion if its working:)

• ###### Re: How to create a flag with two conditions?

How do we close the discussion?

• ###### Re: How to create a flag with two conditions?

Marking a response as correct closes the thread

• ###### Re: How to create a flag with two conditions?

No this one was with two if conditions... but 1st condition was similar to the thread u mentioned..