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.

ggallina
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
hrlinder
Not applicable

Re: Calculate Field Name in Script

try ampersand "&" instead of "+"

Temp:

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

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

    FROM Table1;

13 Replies
sunny_talwar
Not applicable

Re: Calculate Field Name in Script

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

Best,

Sunny

balkumarchandel
Not applicable

Re: Calculate Field Name in Script

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

jsanchezh
Not applicable

Re: Calculate Field Name in Script

Hello,

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

hrlinder
Not applicable

Re: Calculate Field Name in Script

try ampersand "&" instead of "+"

Temp:

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

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

    FROM Table1;

ggallina
Not applicable

Re: Calculate Field Name in Script

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!

ggallina
Not applicable

Re: Calculate Field Name in Script

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

ggallina
Not applicable

Re: Calculate Field Name in Script

Thank you Rudolf!

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

How can I declare i?

Thank you again!

ggallina
Not applicable

Re: Calculate Field Name in Script

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

ggallina
Not applicable

Re: Calculate Field Name in Script

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?