Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Add Year Field to Table

Hi i have a question,

I have load data from excel file named [Sales_1549-1608.xlsx]

NB: 1549 and 1608 is yearweek range

i've already transform the data and the result is like this:

add year.png

I want to add one column called year.

So

the result will be like this:

WO     RO     AO     QTY     WEEK_ID     Year

A          D          G         5     W01               2016

A          D          G         5     W02               2016

A          D          G         5     W03               2016

A          D          G         5     W04               2016

A          D          G         5     W05               2016

A          D          G         5     W06               2016

A          D          G         5     W07               2016

A          D          G         5     W08               2016

A          D          G         5     W49               2015

A          D          G         5     W50               2015

A          D          G         5     W51               2015

A          D          G         5     W52               2015

A          D          G         5     W53               2015

I also attach my qlikview file here

thanks

1 Solution

Accepted Solutions
sujeetsingh
Master III
Master III

What is the source of the Year field?

Well i have added it as per your output above.

View solution in original post

6 Replies
sujeetsingh
Master III
Master III

What is the source of the Year field?

Well i have added it as per your output above.

PrashantSangle

Hi,

Use filebaseName() or fileName() to retreive fileName

and using subfield() you can fetch only Year

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PrashantSangle

Capture.PNG

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
SreeniJD
Specialist
Specialist

Hi Sujeet,

Just a small change in your script... Instead of <=49, we have to take <49 only as till 49 it has consider as Year 2015.

if( num(right(WEEK_ID,2))<49,2016,2015) as Year

Correct me If I'm wrong...

Anonymous
Not applicable
Author

Hi All,

Thanks for your idea.

It solve my problem perfectly.

Really glad to have u all.

Thanks

Anonymous
Not applicable
Author

Hi Max,

But how to identify that w49 till w53 is 2015 and w01-208 is 2016 ?