Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

something wrong with my if expression

Hi Guys,

I'm proberly doing something wrong, I have a filename: Commercial_ED_REL_GCPR_272022793_2011-12-29.txt

Where I allready extracted the Ordernumber from by using the following expression:

     mid(filename(),Index(filename(),'PR_')+3,9) as OrderNo,

Now I'm trying to add an if statement to it, if the number after 'PR_'starts with 27 then 'True' otherwise 'False'.

This is my expression:

     if(mid(filename(),index(filename(),'PL_')+3,2)='27','True','False') as Test,

There must be something wrong with my expression since I only get False as a result.

Hope someone can help

Thanks in advance!

Carter

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Shouldn't you use 'PR_' as second argument to the index function?

View solution in original post

4 Replies
swuehl
MVP
MVP

Shouldn't you use 'PR_' as second argument to the index function?

stephencredmond
Luminary Alumni
Luminary Alumni

Hi,

I find that too many functions and subfunctions can confuse me so I will generally turn to the Preceeding Load to do this type of thing:

Load

          if(Left(OrderNo, 2)=27, 'True', 'False') As Is27,

          *;

Load

          SubField(filename, '_', 5) as OrderNo,

          *;

LOAD Field1,

     Field2,

     Field3,

     FileName() as filename

FROM

[Commercial_ED_REL_GCPR_272022793_2011-12-29.txt]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Note that I have used the SubField function to extract the OrderNo - I think that it is a better method if the filename has a fixed structure like this.

Regards,

Stephen

Not applicable
Author

Hi Stefan,

Thanks! I'm appearantly not so sharp at the end of the day. lol But

you are right! It should have been 'PR_' instead of 'PL'_.

Carter

On donderdag 2 februari 2012 at 6:20 PM, swuehl wrote:

QlikCommunity

Re: something wrong with my if expression created by

swuehl in Development (QlikView Desktop) - View the full discussion

Not applicable
Author

Thanks Stephen! That to is a very good approch

On donderdag 2 februari 2012 at 6:24 PM, Stephen Redmond wrote:

QlikCommunity

Re: something wrong with my if expression created by

Stephen Redmond in Development (QlikView Desktop) - View the full

discussion