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

How to extract Month,Year,YearMonth fields from Excel file name?

Hi Experts,

I have two .xlsx files named

Global IT Assesment - vilot Apps 20171029 V1 -Oct Metrics

Global IT Assesment - vilot Apps 20171118 V1 -Nov Metrics

From these excel file names need to extract the Date,Month,Year and YearMonth fields in the script.

Please help me how to extract the above date fields from the file name.

Please find the excel source files.

Thanks in advance.

1 Solution

Accepted Solutions
micheledenardi
Specialist II
Specialist II

use FileName() Funcion to get the xlsx name and then use string and date functions to get the value you want.

2017-12-04 12_10_28-QlikView x64 Personal Edition - [C__Users_Michele.Denardi_Desktop_Test.qvw_].png

Global IT Assesment:

LOAD

    OR,

     R,

     A,

     G,

     makedate(mid(FileName(),34,4),mid(FileName(),38,2),mid(FileName(),40,2)) as Date,

     monthname(makedate(mid(FileName(),34,4),mid(FileName(),38,2),mid(FileName(),40,2))) as MonthName,

     mid(FileName(),38,2)&'/'&mid(FileName(),34,4) as Year_Month,

     mid(FileName(),34,4) as Year,

     mid(FileName(),38,2) as Month,

     mid(FileName(),40,2) as Day

FROM

(ooxml, embedded labels, table is Sheet1);

Apply the same logic for the second xlsx

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
devarasu07
Master II
Master II

Anil_Babu_Samineni

First you need to load all data to make good data model. That model may from fact table. From fact table, You can extract and develop only one date field after you can use Month(), Year() .... for DateField..

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
micheledenardi
Specialist II
Specialist II

use FileName() Funcion to get the xlsx name and then use string and date functions to get the value you want.

2017-12-04 12_10_28-QlikView x64 Personal Edition - [C__Users_Michele.Denardi_Desktop_Test.qvw_].png

Global IT Assesment:

LOAD

    OR,

     R,

     A,

     G,

     makedate(mid(FileName(),34,4),mid(FileName(),38,2),mid(FileName(),40,2)) as Date,

     monthname(makedate(mid(FileName(),34,4),mid(FileName(),38,2),mid(FileName(),40,2))) as MonthName,

     mid(FileName(),38,2)&'/'&mid(FileName(),34,4) as Year_Month,

     mid(FileName(),34,4) as Year,

     mid(FileName(),38,2) as Month,

     mid(FileName(),40,2) as Day

FROM

(ooxml, embedded labels, table is Sheet1);

Apply the same logic for the second xlsx

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
antoniotiman
Master III
Master III

May be this

SET DateFormat='YYYYMMDD';

LOAD *,Month(Date) as Month,Year(Date) as Year,MonthName(Date) as MonthName
Where Not IsNull(Date);
LOAD *,Date(Alt(Date#(SubField(FileName(),' ')))) as Date
FROM
[Global IT Assesment - vilot Apps 20171029 V1 -Oct Metrics.xlsx]
(ooxml, embedded labels, table is
Sheet1);