
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to extract the date part from excel file names and store it as a column?
hi all,
I request your help to extract the date part from excel file names and store it as a column. Basically I have multiple files, almost 100's of them .I want to extract the date (in any date format )from their file name and place it as a date column and finally store all the columns into one qvd, so that I can identify individual file in my final data set.
here are the file names eg: I want to extract the yellow part and store.
regards,
Sahana
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you already have a loop in order to read all the files then you can use filebasename() when reading the file. You will get a string similar to this: 'Daily Inventory__5000000_20210105070700'
You will need to extract the desired substring to get your desired date. This could be done in many ways, depending on the variation on your file names, but for your sample this should work:
Left(SubField(filebasename(), '_', - 1),8) as Date
Qlik Community MVP


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you already have a loop in order to read all the files then you can use filebasename() when reading the file. You will get a string similar to this: 'Daily Inventory__5000000_20210105070700'
You will need to extract the desired substring to get your desired date. This could be done in many ways, depending on the variation on your file names, but for your sample this should work:
Left(SubField(filebasename(), '_', - 1),8) as Date
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could also take a look at this page for other string manipulating funtions: https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Strin...
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Vegar,
thanks for your response. I tried the solution you sent but it gives me an error at the bracket. Not sure about the reason. Can you help?
Regards,
Sahana


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thankyou very much Settu. It works.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for spotting my mistake. I've edited my previous response to SubField()
Qlik Community MVP
