Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

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

1 Solution

Accepted Solutions
datanibbler
Champion
Champion
Author

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

View solution in original post

7 Replies
giakoum
Partner - Master II
Partner - Master II

a sample would help

datanibbler
Champion
Champion
Author

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

jonathandienst
Partner - Champion III
Partner - Champion III

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
Champion
Champion
Author

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
Partner - Master II
Partner - Master II

Mark your answer as correct

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

datanibbler
Champion
Champion
Author

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
Partner - Master II
Partner - Master II

you did well