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

Specifying a table for the value of a variable

Hi All!

How can I enter the years in the Yearlist table into the vLoadedPartitionList variable?

 

LET vStartingYear = Year(Today()) - 4;
LET vTargetYear = Year(Today());

[YearList]:
LOAD 
    $(vStartingYear) + RowNo() - 1 AS Year
AUTOGENERATE 
    $(vTargetYear) - $(vStartingYear) + 1;

LET vLoadedPartitionList = ???; // Partition List. If it is not null, then only this partition(s) will be loaded. (for yearly partition(s): YYYY (eg: '2019, 2020')

 

Thanks for all the help!

Labels (1)
1 Solution

Accepted Solutions
AgatheClero
Partner - Contributor II
Partner - Contributor II

Hi @bajor14 ,

Not sure to understand your question, but if you want to store the years which is in your table YearList into your variable vLoadedPartitionList, you can do this :

LET vStartingYear = Year(Today()) - 4;
LET vTargetYear = Year(Today());

[YearList]:
LOAD 
    $(vStartingYear) + RowNo() - 1 AS Year
AUTOGENERATE 
    $(vTargetYear) - $(vStartingYear) + 1;
    
    
    
LET vCountYear  = FieldValueCount('Year');
Trace Number of years : $(vCountYear);

SET vYear_init = 1;

For i=1 to $(vCountYear)
  If '$(vYear_init)' = 1 then
    LET vYear_init = FieldValue('Year',$(i));
  Else
    LET vYear_init = '$(vYear_init)' & ',' & FieldValue('Year',$(i)); 
  End If
Next  

LET vLoadedPartitionList = chr(39) & '$(vYear_init)' & chr(39);

Trace vLoadedPartitionList = $(vLoadedPartitionList);

 

Hope this helps.

Regards,

Agathe.

View solution in original post

2 Replies
AgatheClero
Partner - Contributor II
Partner - Contributor II

Hi @bajor14 ,

Not sure to understand your question, but if you want to store the years which is in your table YearList into your variable vLoadedPartitionList, you can do this :

LET vStartingYear = Year(Today()) - 4;
LET vTargetYear = Year(Today());

[YearList]:
LOAD 
    $(vStartingYear) + RowNo() - 1 AS Year
AUTOGENERATE 
    $(vTargetYear) - $(vStartingYear) + 1;
    
    
    
LET vCountYear  = FieldValueCount('Year');
Trace Number of years : $(vCountYear);

SET vYear_init = 1;

For i=1 to $(vCountYear)
  If '$(vYear_init)' = 1 then
    LET vYear_init = FieldValue('Year',$(i));
  Else
    LET vYear_init = '$(vYear_init)' & ',' & FieldValue('Year',$(i)); 
  End If
Next  

LET vLoadedPartitionList = chr(39) & '$(vYear_init)' & chr(39);

Trace vLoadedPartitionList = $(vLoadedPartitionList);

 

Hope this helps.

Regards,

Agathe.

bajor14
Contributor
Contributor
Author

Hi @Agathe!

Perfect! That's exactly how I wanted it! Thank you very much!!!!!