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

getting Column names based on loop

I am loading Quantity from a table. Quantity field is sequencial as shown below. 

LOAD
Q_REL_SUPLR_MO_1,
Q_REL_SUPLR_MO_2,
Q_REL_SUPLR_MO_3,
Q_REL_SUPLR_MO_4,
Q_REL_SUPLR_MO_5,
and so on 

Requirement is to load fields based on the current month. For example if current month is October then it should Mo1,Mo2 and Mo3. if current month is nov then Mo1 and Mo2 

2 Replies
Frank_Hartmann
Master II
Master II

maybe something like this:

LET actualmonth = num(month(MonthName((now()))- 1*12)); 

Test: 
Load *, subfield(Field,'_',5) as subfield;
Load * inline [
	Field
	Q_REL_SUPLR_MO_1,
	Q_REL_SUPLR_MO_2,
	Q_REL_SUPLR_MO_3,
	Q_REL_SUPLR_MO_4,
	Q_REL_SUPLR_MO_5
] 
where $(actualmonth)<= 12-subfield(Field,'_',5);
raghuchowdary
Contributor II
Contributor II

Do you want to show in a straight table?

In a simple way , add columns for each field and add " show column "conditions based on the months accordingly.

 

If your requirement is different , please explain more clearly.