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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Problem in a dynamically adapting code

Hi,

I have a code loading a list which changes slightly every month:

- Starting from column 35 or so (counting from the left), there are columns for the total_operating_hrs;
   => In March (now), there are 2 columns there - one for Jan, one for Feb
   => In April, there will be one more for March
    ... and so on till December.

I have a rather complex loop to generate

- a variable holding the field_name and

- a variable holding an alias_name

for every column from 35 to 44.

=> When there are no operating_hrs in the column (I check the field_names), then

- the variable for the field_name says "dummy_[nr.] and

- the variable for the alias_name says the same.

My issue now is this:

- When the field_name_variable says 'dummy_36' for instance, I can only load that when I put it in quotes as it is not a valid
    field_name. There is an error_message if I don't use quotes.
  <=> When there is a valid field_name in that variable, it is still in quotes, so the LOAD will give me the field_name in every record instead of the contents.

I'm just thinking of maybe doing it another way altogether, but I'd be happy if there was a possible fix to this - I put a lot of work into first generating all the columns (up to the one where November will be) and then deleting the bogus ones again.

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
marcus_sommer

Hi DataNibbler,

maybe you could load these data without embedded labels/fieldnames only as columns and used afterwards a rename-statement.

- Marcus

View solution in original post

4 Replies
marcus_sommer

Hi DataNibbler,

maybe you could load these data without embedded labels/fieldnames only as columns and used afterwards a rename-statement.

- Marcus

datanibbler
Champion
Champion
Author

Hi Marcus,

yes. I was thinking about something like that. I could use another loop afterwards to just delete the columns I don't need.

It doesn't seem to be possible to make QlikView use quotes in the LOAD only when the field_variable says 'dummy' and use [] otherwise (as the field_name contains BLANKs), I always get an expression_error when I try.

I will now try changing the strategy altogether and load it in another way.

datanibbler
Champion
Champion
Author

Okay,

I've made the first part. The fields are now all loaded normally, only the ALIAS_names are different:

- When there is an operating_hrs field, I need an alias_name that is shorter than the field_name (the user should be
   able on the GUI to select which of all these fields are to be displayed)

- When there is some other field, the alias_name should still be 'dummy_[nr]'

That works now. Now I just have to modify the second loop to remove all the fields that are no longer required.

prieper
Master II
Master II

Hi,

cannot imagine your data,

would it be possible to upload just an example of the headerlines und underlying data?

Will this be generated from Excel? or csv?

Peter