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

combining two scripts to 1

Hi There,

I'm quit new to qlikview and therefore still struggeling with "advanced" scripting.

if(Interval(Date(Date#(POD,'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY hh:mm') - date(Date#(DEP, 'DD-MM-YYYY hh:mm'),'DD-MM-YYYY hh:mm'), 'd hh:mm') <= 8,'ON TIME','LATE') as Status.


if(
Interval(Date(Date#(POD, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY hh:mm') -date(Date#(DEP, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY hh:mm'), 'd hh:mm') <= 7,'ONTIME','LATE') as StatusII.


How can I combine both scripts to 1 script/field? Suppose I want to state that shipments to destination [which is the fieldname] “JFK” have a maximum of 8 days and shipments to “DBX” have a maximum of 7 days. Should I use another if statement?

I want to do this so I don’t have to create a field for each specific ‘requirement’.

Thanks in advance!!!

Regards,

iSam

12 Replies
lucas4bi
Partner - Creator
Partner - Creator

If think you could use another IF inside that expression, instead of <=8 you could put:

...<= IF( destination="JFK",8,

          IF( destination="DBX",7........))   , 'ON TIME','LATE') as STATUS.

so now you can have only one STATUS field for each destitnation.

let me know if it works ok for you

(i think you can make your code even easyer, you dont need all that 'Date(date#(....))' functions to format your dates,

Date#() is to format 'text' into a date, Date() is to format a numeric/date field)

Anonymous
Not applicable
Author

Thanks for your help: Unfortunately Qlikview says it can’t find the field name “BJS”. However when I look in the data source and in the qlikview application “BJS” does exits.

What am I doing wrong?

if(interval(Date#(POD, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY') - Date#(DEP, 'DD-MM-YYYY hh:mm'),'DD-MM-YYYY'), 'D'<= If(="BJS", 8, If(="IZM,AMS", 7)), 'OnTime', 'Late' as Status,

lucas4bi
Partner - Creator
Partner - Creator

Sorry, when you compare a string you have to use a single ' and not ",

i wrote wrong before, you should write the destitnation like this 'BJS'.

Anonymous
Not applicable
Author

Thanks a lot for your help!!!! It seems to be OK now!!

Anonymous
Not applicable
Author

I think cheered too early L. When I add the new field to a chart, it seems to be a miss calculation. I get to different results:

One charts says 74 onTime, another say 51 ontime :S. It’s confussing.

This is the script for Status2:     if(Interval(Date(Date#(POD, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY') - Date(Date#(DEP, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY'), 'D')<=7, 'OnTime', 'Late') as Status2,

And this is the expression for StatusX:  if(interval(Date(Date#(POD, 'DD-MM-YYYY hh:mm'), 'DD-MM-YYYY') - Date(Date#(DEP, 'DD-MM-YYYY hh:mm'),'DD-MM-YYYY'), 'D')<= If(Re: combining two scripts to 1='BJS', 8, If(Re: combining two scripts to 1='IZM' or 'AMS', 7)),  'OnTime', 'Late') as StatusX,  //the one you help me with J

Both of the above charts have the same chart expression:  Count({<Destination={'IZM', 'AMS'}>} TransitTime +1) 

Is the problem within the chart expression or script?

Thanks for all your help!!!

iSam

Not applicable
Author

Ich werde ab 05.09.2011 nicht im Büro sein. Ich kehre zurück am

23.09.2011.

Ich werde Ihre Nachrichten nach meiner Rückkehr beantworten.

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Verwertung des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt.

Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank!

Not applicable
Author

Ich werde ab 05.09.2011 nicht im Büro sein. Ich kehre zurück am

23.09.2011.

Ich werde Ihre Nachrichten nach meiner Rückkehr beantworten.

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Verwertung des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt.

Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank!

Not applicable
Author

Ich werde ab 05.09.2011 nicht im Büro sein. Ich kehre zurück am

23.09.2011.

Ich werde Ihre Nachrichten nach meiner Rückkehr beantworten.

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Verwertung des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt.

Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank!

Not applicable
Author

Ich werde ab 05.09.2011 nicht im Büro sein. Ich kehre zurück am

23.09.2011.

Ich werde Ihre Nachrichten nach meiner Rückkehr beantworten.

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Verwertung des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt.

Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank!