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

Set variable for january current year

 

Hi,

I have a requirement to load monthly files to accumulative file. Starting from January every year to last month file. 

For example, the january 2019 qvd will contain january 2019 excel file, February 2019 qvd will contain january 2019 and febuary 2019 files. And next year January file will contain next year january file and accumulate starting from January next year.

Below is my code currently, however i'd like to know what variable I can use to change with '201901' as I don't want my user to need to change the variable every year.

 

Let vDateFrom = '201901';        //start from 201901 onwards
LET vDateTo = date(AddMonths(today(),-1),'YYYYMM');       

For vYYYYMM = $(vDateFrom) to $(vDateTo)

TEMP_SPEND_YTD:
LOAD
%Contract&'-'&%YearMonth as %Contract_YearMonth,
Spend_YTD,
%Contract,
%YearMonth
FROM [lib://T1_SPEND_YTD/T1_SPEND_YTD_$(vYYYYMM).qvd]
(qvd);


SPEND_YTD:
[%Contract_YearMonth],
Spend_YTD
Resident TEMP_SPEND_YTD;
Drop Table TEMP_SPEND_YTD;

Store SPEND_YTD into [lib://T2_ACTUAL REALISED/T2_ActualRealised_$(vYYYYMM).qvd](qvd);

Next;

 

 

Thanks

Labels (1)
1 Reply
KennyJ97
Contributor
Contributor

Try Date(YearStart(now()),'YYYYMM') in a variable. This will return 201901, next year 202001.