Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

For loop Problem

Hi

PFA

Labels (1)
1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Please find script below

FOR i = 1 to Month(Today()) -1

  LET vMonthYear = Text(Date(MakeDate(Year(Today()), i), 'MMM YYYY'));

  If i = 1 then

  Data:

  LOAD organizationLookupDesc,

      corporateFunctionLookupDesc,

      employeeRootId,

      lastName,

      firstName,

      '$(vMonthYear)' AS SheetName    

  FROM

  [EMEA HEADCOUNT 2014_GMBH-Anonym.xlsx]

  (ooxml, embedded labels, table is '$(vMonthYear)');

  ELSE

  Concatenate(Data)

  LOAD organizationLookupDesc,

      corporateFunctionLookupDesc,

      employeeRootId,

      lastName,

      firstName,

      '$(vMonthYear)' AS SheetName      

  FROM

  [EMEA HEADCOUNT 2014_GMBH-Anonym.xlsx]

  (ooxml, embedded labels, table is '$(vMonthYear)');

  ENDIF

NEXT

Regards,

Jagan.

View solution in original post

1 Reply
jagan
Partner - Champion III
Partner - Champion III

Hi,

Please find script below

FOR i = 1 to Month(Today()) -1

  LET vMonthYear = Text(Date(MakeDate(Year(Today()), i), 'MMM YYYY'));

  If i = 1 then

  Data:

  LOAD organizationLookupDesc,

      corporateFunctionLookupDesc,

      employeeRootId,

      lastName,

      firstName,

      '$(vMonthYear)' AS SheetName    

  FROM

  [EMEA HEADCOUNT 2014_GMBH-Anonym.xlsx]

  (ooxml, embedded labels, table is '$(vMonthYear)');

  ELSE

  Concatenate(Data)

  LOAD organizationLookupDesc,

      corporateFunctionLookupDesc,

      employeeRootId,

      lastName,

      firstName,

      '$(vMonthYear)' AS SheetName      

  FROM

  [EMEA HEADCOUNT 2014_GMBH-Anonym.xlsx]

  (ooxml, embedded labels, table is '$(vMonthYear)');

  ENDIF

NEXT

Regards,

Jagan.