Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Store a QVD with a Variable Name and caluculated value

I want to add current year and previous period to the filename

'$(vYear)'&P'max(Period)-1'&filename.qvd(qvd);

Can someone tell me if this is correct?

Thanks!

5 Replies
Clever_Anjos
Employee
Employee

LET vYear=2015;

LOAD

Max(Period) as mPeriod

resident yourtable;

Let mPeriod = peek('mPeriod');

'$(vYear)'&P'$(mPeriod)-1'&filename.qvd(qvd);

should work

Anonymous
Not applicable
Author

thank you!

I have a small correction here,

If month = jan ,period should be previous year's period i.e., 2014P12filename.qvd

other than jan period should be current year's previous period i.e., 2015P2filename.qvd through 2015P11filename.qvd

can u help me with this.

Thanks!

Clever_Anjos
Employee
Employee

This should work:

table: // fake table, please use yours

LOAD AddMonths(today(),-RecNo()) as Period AutoGenerate 30;

tmp:

LOAD

Max(Period) as mPeriod

resident table;

Let mPeriod = num(month(AddMonths(peek('mPeriod'),-1)));

Let vYear = year(AddMonths(peek('mPeriod'),-1));

drop Table tmp;

store atable into [$(vYear)P$(mPeriod)filename.qvd](qvd);

Anonymous
Not applicable
Author

No this is not working..

It gave me 1899P11Filename

Clever_Anjos
Employee
Employee

Would you mind sharing a sample of your data?

The year problem is related to how your data is stored