Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

stevelord
Valued Contributor

parse file name of varying length to make field values

Hi, I have a heap of files named like this lastname_firstname.pdf

Since they are pdfs, I can't load the contents of the files (to my knowledge).  The request is simply for a view of the list of the files so reps can see whose files we've received.  I could just load filename() as filename and sort alphabetically, but I would like to make a couple of clean fields for first name and last name for ocd/tidiness reasons.

I feel like the answer is in my head or on a qvw I have somewhere, but if someone can hit me with the function here real quick it'd save me time rummaging around and get you some easy correct answer credit.   (and be helpful to others with similar questions.)

1 Solution

Accepted Solutions
Not applicable

Re: parse file name of varying length to make field values

Hi Steve,

can split based on the _ char.

SubField(filename(),'_',1)      As Firstname

SubField(filename(),'_',2)      As lastname

hope that helps

Joe

3 Replies
Not applicable

Re: parse file name of varying length to make field values

Hi Steve,

can split based on the _ char.

SubField(filename(),'_',1)      As Firstname

SubField(filename(),'_',2)      As lastname

hope that helps

Joe

stevelord
Valued Contributor

Re: parse file name of varying length to make field values

Thanks, I just found that answer too.   (Subfield() was the name of the function I was drawing a blank on.  Rarely had to use it.)

Not applicable

Re: parse file name of varying length to make field values

No problem, glad to help and kudos on the OCD ness, one of my favourite curveball questions to ask in interviews

Community Browser