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

How to extract last three years via a for loop?

Hi everybody,

i'm here because I'm wondering whether there's any possibility to extract dynamically last three years from a table with for each...next loop instead that with a simple where.

Let us suppose we have a table with a measure column and a Year column.

Year column range goes from 2012 to 2023 and counting for next years.

Instead of loading table with "Where YearColumn >= Year(Now()))-3 i would like to get to that result through a loop.

Is there any chance?

 

Thank you

 

Attached here you will find an example of the table

 

 

 

Labels (3)
4 Replies
MartW
Partner - Specialist
Partner - Specialist

 

the table you want to extract(your example), is this the only table or are the multiple tables with the same structure? if this is the case then a loop would be beneficial. otherwise the where statement will be faster.

so file 1.xlsx 

Year, Measure

2012, 1000

... , ...

2023, 10

so file 2.xlsx 

Year, Measure

2012, 15000

... , ...

2023, 1890

MarcoWedel

Yes, that's possible.

What issue do you see in using a where condition instead?

aresb
Creator
Creator
Author

Hi @MartW 

 

The table is part of a link table with differente structure among tables.
So, the for each statement should be applied only to this table.

Does it make sense applying the for loop ?

aresb
Creator
Creator
Author

Hi @MarcoWedel 

We were discussing with our collegues on which would be the faster and best solution between Where condition and for loop.

Do you have any advice?


Thank you