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: 
raju_salmon
Creator II
Creator II

How to remove last filename from path

Hi,

I have data something like below, and i need to remove last folder/filename from the path and create a new field.

Can anyone help me what functions i need to use here... path depth is not constant here.

Path
c:\windows\system32\wercplsupport.dll
C:\Windows\System32\Tasks\WPD\SqmUpload_S-1-5-21-3480950271-2841014456-3714682224-1000
C:\Windows\System32\Tasks\UpdaterEX
C:\Windows\system32\tasks\PrintProjects Communicator
C:\Windows\system32\tasks\PrintProjects Communicator
C:\Windows\System32\Tasks\ParetoLogic Registration3
C:\Windows\system32\tasks\CorelUpdateHelperTaskCore
C:\Windows\system32\tasks\CorelUpdateHelperTaskCore
c:\windows\system32\rundll32.exe
c:\windows\system32\rundll32.exe
c:\windows\system32\rundll32.exe
c:\windows\system32\provsvc.dll
c:\windows\system32\prodad-codec.dll
c:\windows\system32\es.dll
c:\windows\system32\drivers\swdumon.sys
C:\Windows\Prefetch\WPWIN18.EXE-4760BC11.pf
C:\Windows\Prefetch\PRINTSERVER180.EXE-FF650BD4.pf
C:\Windows\Prefetch\NASVC.EXE-1366244C.pf
C:\Windows\Prefetch\EXPLORER.EXE-A80E4F97.pf
C:\Windows\Prefetch\COMMUNICATOR.EXE-B68D51A3.pf
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\WordPerfect Office X8\Presentations Graphics X8.lnk
|user_1|\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Newegg Download Manager\NeweggDownloadManager.lnk
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Like this:

Left(fieldname, Index(fieldname, '\', -1) - 1) as RemainingPath,

Index with a -ve start searches backwards from the end of the string.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
Anonymous
Not applicable

Try this:

=SubField(Path,'\',substringcount(Path,'\')+1)

raju_salmon
Creator II
Creator II
Author

Thank you, actually it is giving result of last folder.

But i would like to create a new field where it exclude last folder and gives remaining path.

jonathandienst
Partner - Champion III
Partner - Champion III

Like this:

Left(fieldname, Index(fieldname, '\', -1) - 1) as RemainingPath,

Index with a -ve start searches backwards from the end of the string.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
tresesco
MVP
MVP

Try like:

=Left('YourString',index('YourString','\',-1))

Anonymous
Not applicable

As you want to remove, it would be better to do so:

Left(Path,

  index(Path,

  SubField(Path,'\',substringcount(Path,'\')+1))-1)