Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

want to fill a new table with two fields from a table

Good Morning,

I am new to Qlikview.

I hope someone will help with the following exercise.

I load a table from an Excel spreadsheet "Numeri e Lettere.xls" then I want to create a table with two numbers (i.e.: 4 and 5)

NumeriLettere
1a
2b
3c
4d
5e
6f
7g
8h
9i
10j


This is the script:

NumerieLettere:

Load

Numeri

,

Lettere

FROM

[Numeri e Lettere.xls]

(

biff, embedded labels, table is [Foglio1$]);







tempNumberLetter:

LOAD

Numeri

as Numbers,

Lettere

as Letters

Resident

NumerieLettere;

NumberLetterTable:

LOAD

Numbers

Resident

tempNumberLetter;

for

let

load

'$(varmyNumber)' as myNumberCharacter

AutoGenerate

(1);

next

DROP

Table tempNumberLetter; varmyNumber = peek('Numbers', $(a), '[NumberLetterTable]');

[Lista Numeri e Lettere]:

a=3 to 4

as you can see only the number 4 is shown:

I will appreciate your help

Thanks

Antonio



13 Replies
Anonymous
Not applicable
Author

Perfect it works

Thank you allSmile


for a=3 to 4
//let varmyNumber = peek('Numbers', $(a), '[NumberLetterTable]');

[Lista Numeri e Lettere]:
load '$(a)' as myNumberCharacter
//load '$(varmyNumber)' as myNumberCharacter
AutoGenerate(1);
next


Miguel_Angel_Baeyens

Hello,

Unless there is no other way to get what you want, I'd avoid the use of loops because of poor performance and ease of use of alternatives.

Anyway, the Peek() function takes in its three parameters version, both field and table name as literal (string). So changin your current line to this one (removing square brackets from [NumberLetterTable]) should return as expected:

peek('Numbers', $(a), 'NumberLetterTable');


Hope that helps.

tresesco
MVP
MVP

Hi Miguel,

Yours is a very valid point. may be my understanding was not exact, i suggested the solution assuming that the data (3,4) is not there in the loaded data(as i explained in my prev post too), so autogeneration(generate the data of your own) is the only option and loop is a consequent. Otherwise you are right.

Regards, tresesco

Anonymous
Not applicable
Author

I restored "peek" and got rid of the brackets and everything works fine: Smile

Thank you all

Antonio