Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculate Field Name in Script

Hi,

I have a question, I have a table in DB with many field that have this name:

Table1:

ItemID01

ItemID02

ItemID03

...

Quantity01

Quantity02

Quantity03

...

I need to load every Item field anf quantity with the same field name.

I try with this:

For i=1 to 3

Temp:

LOAD 'ItemID' + text(num(i,'00')) AS ItemID.

   'Quantity' + text(num(i,'00')) AS Quantity

    FROM Table1;

but seem that QlikView dont resolve names of field 'ItemIDxx and Quantityxx.

SO I dont know wich is the right syntax.

Please can you help me?

Thank you very much.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

try ampersand "&" instead of "+"

Temp:

LOAD 'ItemID' & text(num(i,'00')) AS ItemID.

   'Quantity' & text(num(i,'00')) AS Quantity

    FROM Table1;

View solution in original post

13 Replies
sunny_talwar

Not exactly sure about what you are trying to do? Can you post a sample QV  file??

Best,

Sunny

Anonymous
Not applicable
Author

why you are not selecting field names directly from table (load wizard).

jsanchezh
Partner - Creator
Partner - Creator

Hello,

I don't understand what you are tring to do either. Do they have the same values? are you traying to concatenate them?

Anonymous
Not applicable
Author

try ampersand "&" instead of "+"

Temp:

LOAD 'ItemID' & text(num(i,'00')) AS ItemID.

   'Quantity' & text(num(i,'00')) AS Quantity

    FROM Table1;

Anonymous
Not applicable
Author

Hi,

here QVW file.

I need to have the names of fields (for example if i is equal 2 I need to have ItemID02 and Quantity02).

I dont know if this is possible, if not is a great prblem, in database I have an arry for every record.

Thank you!

Anonymous
Not applicable
Author

These is different field with different value and I must to work with this.

Anonymous
Not applicable
Author

Thank you Rudolf!

But now QlikView say: "Field i dont exist".

How can I declare i?

Thank you again!

Anonymous
Not applicable
Author

I need all fields, I need to take the array of fields and use some that was a different record...

Anonymous
Not applicable
Author

For example:

FROM (Database Table):

Table1:

  IDKEY  ItemID01 ItemID02 ItemID03 Quantity01 Quantity02 Quantity03
      1           A                 B          C              5                 10             8
      2           E                 A          D              8                   1             9

TO:

Temp (Qlikview Table):

IDKEY ItemID Quantity

    1          A          5

    1          B         10

    1          C           8

    2          E           8

    2          A           1

    2          D           9

Is it impossible?