Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Qlik Folks,
Why can't I write multiple if's like this, only 1st statement is working as expected.
if(len(trim([Begin Date]))=0 and len(trim([End Date]))=0, 'Closeouts','Excl Closeout'),
if(len(trim([Begin Date]))>0 and len(trim([End Date]))>0, 'Closeouts','Excl Closeout')
as CloseoutDesc
expected output attached
You should write nested ifs like this:
if(condition 1, true, if(condition 2, true, false)) as field1
Your case
if( (len(trim([Begin Date]))=0 and len(trim([End Date]))=0) // 1 condition OR (len(trim([Begin Date]))>0 and len(trim([End Date]))>0), // 2 condition 'Closeouts','Excl Closeout') as CloseoutDesc
also you can use >= operator and simplify if
if(len(trim([Begin Date]))>=0 and len(trim([End Date]))>=0, 'Closeouts','Excl Closeout') as CloseoutDesc
Unless I'm missing something, your second IF is exactly the same as the first and will never be executed.
Try:
if(len(trim([Begin Date]))=0 and len(trim([End Date]))=0, 'Closeouts','Excl Closeout') as CloseoutDesc
You should write nested ifs like this:
if(condition 1, true, if(condition 2, true, false)) as field1
Your case
if( (len(trim([Begin Date]))=0 and len(trim([End Date]))=0) // 1 condition OR (len(trim([Begin Date]))>0 and len(trim([End Date]))>0), // 2 condition 'Closeouts','Excl Closeout') as CloseoutDesc
also you can use >= operator and simplify if
if(len(trim([Begin Date]))>=0 and len(trim([End Date]))>=0, 'Closeouts','Excl Closeout') as CloseoutDesc
difference > & = to signs on both the if's
Awesome this is what am exactly looking for