Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If Else Condition

Dear all,

I have two date fields PO_DATE and INVOICE_DATE.. Now i wants to write a expression for two fields. My logic is below. How can i implement my logic using "IF Else " statement.

If PO_DATE=INVOICE_DATE then "Online" elseif  interval(PO_DATE-Invoice_DATE,'DD') >=2 then 'twodays' elseif interval(PO_DATE-Invoice_DATE,'DD') >=10 then 'Tendays' else interval(PO_DATE-Invoice_DATE,'DD') >=30 then "Thirtydaysmore"

Regards,

Masba

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

If(   PO_DATE = INVOICE_DATE , " Online" , if   ( interval(Invoice_DATE - PO_DATE,'DD') <=2,  "2daysmore", if  (interval(Invoice_DATE - PO_DATE,'DD') <=10, "  10daysmore", if  (interval(Invoice_DATE - PO_DATE,'DD') <=30, "30daysmore", "30daysmore")   )    )   )

View solution in original post

5 Replies
Anonymous
Not applicable
Author

If(   PO_DATE = INVOICE_DATE , " Online" , if   ( interval(Invoice_DATE - PO_DATE,'DD') <=2,  "2daysmore", if  (interval(Invoice_DATE - PO_DATE,'DD') <=10, "  10daysmore", if  (interval(Invoice_DATE - PO_DATE,'DD') <=30, "30daysmore", "30daysmore")   )    )   )

anbu1984
Master III
Master III

If(PO_DATE=INVOICE_DATE,"Online",

if(interval(PO_DATE-Invoice_DATE,'DD')>=30 ,"Thirtydaysmore",

if(interval(PO_DATE-Invoice_DATE,'DD') >=10, 'Tendays' ,

if(interval(PO_DATE-Invoice_DATE,'DD') >=2 , 'twodays' ))))

er_mohit
Master II
Master II

Hi

For that first of all The date format for both date fields must same, then  need to use number format for both date fields using either Floor or Num function . Doing this way it becomes easily to match the date between two fields.

After doing this use your if else Statement like below

If(Floor(Date(PO_DATE))=Floor(Date(INVOICE_DATE)),'Online',

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE)) >=2 , 'Twodays' ,

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE)) >=10, 'Tendays',

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE))>=30 ,'Thirtydaysmore'

))))

Hope it helps

Regards

Mohit

Anonymous
Not applicable
Author

in ur case.. 5, 11 , 30 also greater than 2 so loop will not go to >=10 and >=30 cases..it ll come out at >=2 and result would be 2days more....sorry if I am wrong.....

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Mohit's statement is correct, except for the order of the Ifs:

If(Floor(Date(PO_DATE))=Floor(Date(INVOICE_DATE)), 'Online',

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE)) >= 30 ,'Thirtydaysmore',

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE)) >= 10, 'Tendays',

if(Floor(Date(PO_DATE))-Floor(Date(Invoice_DATE)) >= 2 , 'Twodays'

))))

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein