Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
Contributor 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
Highlighted
MVP
MVP

Re: How to remove last filename from path

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
Highlighted
Contributor III

Re: How to remove last filename from path

Try this:

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

Highlighted
Contributor II

Re: How to remove last filename from path

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.

Highlighted
MVP
MVP

Re: How to remove last filename from path

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

Highlighted
MVP
MVP

Re: How to remove last filename from path

Try like:

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

Contributor III

Re: How to remove last filename from path

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

Left(Path,

  index(Path,

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