Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

datanibbler
Esteemed Contributor

Difficult issue in a loop


Hi,

I have the following issue:

- In my underlying Excel_file, the last column that is currently populated is AG (or 33) (that is like a counter, the total of operating hrs
  as it was in January - the data of February will be available in the first days of March)

  <=> Then, one column will be added next to AG (so the new one will be 34)

  ... and so on every month from now

   => so the last column to be added in the first days of December will be 43 (the December data will be in next year's list)

=> I have a loop running from a counter of 34 to 43, parsing the columns for a keyword to identify whether or not it is a data_field and
    - if it is, it is loaded with an alias_name following a specified naming_format

     - if it is not (example), it is loaded with the value 'dummy_35' and the alias_name 'dummy_35'.

=> All of those fields are included in the LOAD

- Then I have another loop running from a counter of 10 to 20 (on the table just loaded because what used to be column 34 is now column 10, but still called like 'dummy_34')

=> If one of those fields starts with 'dummy', a DROP FIELD statement is constructed in a variable using the Fieldname() function on that table (always adding 24 to the counter to get the correct field_name)

The strange thing is: That loop runs without issues up to the counter of 15 (or 39) - the last fields, although the syntax is exactly the same (those fields are all created in the first loop) are ignored: The IF_function is just skipped as I can see in the Debugger and the commands within that IF_THEN_loop are not executed.

Can anyone tell me what might be the difference that I cannot see there?

Thanks a lot!

Best regards,

DataNibbler

Tags (1)
1 Solution

Accepted Solutions
datanibbler
Esteemed Contributor

Re: Difficult issue in a loop

Hi jonathan,

the issue is solved.

There is just no way of marking a thread as solved unless you mark some answer as "right" - which would be nice, but not correct if you have in the end solved the issue yourself ...

Best regards,

DataNibbler

7 Replies
giakoum
Honored Contributor II

Re: Difficult issue in a loop

a sample would help

datanibbler
Esteemed Contributor

Re: Difficult issue in a loop

Hi ioannis,

I know it would. The thing is just that assembling a sample_file takes a lot of time.

In the meantime, however, I have had an idea myself:

- I have the variable_call (that is, a DROP FIELD statement) WITHIN my loop
=> that means that the table is, from one loop_iteration to the next, collapsed like a telescope

=> By the time the counter reaches 16, the remaining 5 dummy_fields are on the positions 11-15, so the field nr. 16,
     counting from the left, does not begin with 'dummy' anymore.

=> I have to find some way of moving the DROP FIELD statements out of the loop or something ...

Best regards,

DataNibbler

MVP
MVP

Re: Difficult issue in a loop

Hi

This sounds like it could be solved with a cross table load with a wildcard LOAD * to accommodate a varying number of fields. I am not sure from your explanation exactly what it would look like, so I will wait until you can provide that sample if you need more help.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
datanibbler
Esteemed Contributor

Re: Difficult issue in a loop

Hi jonathan,

the issue is solved.

There is just no way of marking a thread as solved unless you mark some answer as "right" - which would be nice, but not correct if you have in the end solved the issue yourself ...

Best regards,

DataNibbler

giakoum
Honored Contributor II

Re: Difficult issue in a loop

Mark your answer as correct

it is possible, you just don't get any points for it (obviously )

datanibbler
Esteemed Contributor

Re: Difficult issue in a loop

Ah, I don't?

That is just what I was not sure of - I wouldn't like to award myself points for getting through some issue, that's why I never marked such threads as solved up to now. But if the system is clever enough to not give me points in that case, I will do so. Thank you!

Hmm ... should I now do as you say or award you the points for telling me ;-)

giakoum
Honored Contributor II

Re: Difficult issue in a loop

you did well

Community Browser