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

Trouble with a loop

Hi

I want to write a loop that will look through two columns of a static table and create all month / year combinations

I then want to use it in this situation in a straight table for searching for a string in a field and creating the date in MM/YYYY format instead of having to write a hundred lines for all different month / year combinations. Can this be done in the load script?

Thanks in advance!

1 Reply
swuehl
MVP
MVP

Maybe like

INPUT:

LOAD * INLINE [

Month, Year

Jan, 2016

Feb, 2017

Mar, 2018

Apr, 2019

May, 2020

Jun, 2021

Jul, 2022

Aug,2023

Sep,2024

Oct, 2025

Nov,2026

Dec,2027

];

TMP:

LOAD Month Resident INPUT;

JOIN

LOAD Year RESIDENT INPUT;

RESULT:

LOAD Date#(Month&Year,'MMMYYYY') as YearMonthDate,

  Month,

  Year

RESIDENT TMP;

DROP TABLE TMP, INPUT;

Haven't understood where and why you want to use the if() statement, though, isn't YearMonthDate what you are looking for?

[And please try to post tables in text formats, not using screenshots]

Regards,

Stefan