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

Help in IF Elseif

Hello Friends,

I have doubt in writing a expression, I have already written a expression in the below, which is working fine. 

if(today() -[DATE] <= 0 ,'ONE', if(today() -[DATE] <= 30 ,'TWO', if(today () -[DATE] <= 60,'THREE', If(today ()- [DATE] <= 90, 'FOUR', 'REST')))) as [Aged];

My requirement is based on different customer like,400 and 54 Its not working for me,

Please help me how to do it.

If((CUSTOMER=400 then

if(today() -(INV_DATE+90) <= 0 ,'ONE', if(today() -(INV_DATE+90) <= 30 ,'TWO', if(today () -(INV_DATE+90) <= 60,'THREE', If(today ()- (INV_DATE+90) <= 90, 'FOUR', 'REST')))));

elseif

CUSTOMER=54 then

if(today() -[Deli_Date] <= 0 ,'ONE', if(today() -[ Deli_Date] <= 30 ,'TWO', if(today () -[ Deli_Date] <= 60,'THREE', If(today ()- [Deli_Date] <= 90,

'FOUR', 'REST'))));

else

if(today() -[Date] <= 0 ,'ONE', if(today() -[Date] <= 30 ,'TWO', if(today () -[Date] <= 60,'THREE', If(today ()- [Date] <= 90, 'FOUR', 'REST'))))) as [Aged];

endif

Regards

Joe

1 Solution

Accepted Solutions
vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hi Joe,

Try This Code:

If(CUSTOMER=400,
if(today() -(INV_DATE+90) <= 0,'ONE',
if(today() -(INV_DATE+90) <= 30,'TWO',
if(today () -(INV_DATE+90) <= 60,'THREE',
If(today ()- (INV_DATE+90) <= 90, 'FOUR', 'REST')))),

If(CUSTOMER=54,
if(today() -[Deli_Date] <= 0 ,'ONE',
if(today() -[ Deli_Date] <= 30 ,'TWO',
if(today () -[ Deli_Date] <= 60,'THREE',
If(today ()- [Deli_Date] <= 90,'FOUR', 'REST')))),

If(today() -[Date] <= 0 ,'ONE',
if(today() -[Date] <= 30 ,'TWO',
if(today () -[Date] <= 60,'THREE',
If(today ()- [Date] <= 90, 'FOUR', 'REST')))))) as [Aged]

View solution in original post

4 Replies
vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hi Joe,

Try This Code:

If(CUSTOMER=400,
if(today() -(INV_DATE+90) <= 0,'ONE',
if(today() -(INV_DATE+90) <= 30,'TWO',
if(today () -(INV_DATE+90) <= 60,'THREE',
If(today ()- (INV_DATE+90) <= 90, 'FOUR', 'REST')))),

If(CUSTOMER=54,
if(today() -[Deli_Date] <= 0 ,'ONE',
if(today() -[ Deli_Date] <= 30 ,'TWO',
if(today () -[ Deli_Date] <= 60,'THREE',
If(today ()- [Deli_Date] <= 90,'FOUR', 'REST')))),

If(today() -[Date] <= 0 ,'ONE',
if(today() -[Date] <= 30 ,'TWO',
if(today () -[Date] <= 60,'THREE',
If(today ()- [Date] <= 90, 'FOUR', 'REST')))))) as [Aged]

Not applicable
Author

Dear Vijay,

Excellent,

it works, can you advise me where I made the mistake because I read the document and I tried.

Thanks a lot......

Joe

vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hey Joe,

Qlikview does not support If ...Then ...Else. Here everything can be achieved by using Comma.

Also most imortent is how you place parenthesis. Once you go through the code you will understand.

Rehards

Vijay

hic
Former Employee
Former Employee

QlikView does indeed support IF ... THEN ... ELSE. But that is a control statement and should be used "outside" the Load-statement.

But in this case you need the if-function: if(<condition>, <value_for_true>, <value_for_false>) inside the Load statement. Which is exactly what Vijay indicates in his answer.
/HIC