Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
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



1 Solution

Accepted Solutions
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


View solution in original post

13 Replies
Anonymous
Not applicable
Author

something got wrong in the copy paste.

I meant

....





for

let .....

a=3 to 4

Anonymous
Not applicable
Author

unfortunately the copy paste does not go in the right way

I hope you understand

Miguel_Angel_Baeyens

Hello,

Why don't you use a WHERE clause?

NumerieLettere:Load Numeri, LettereFROM [Numeri e Lettere.xls](biff, embedded labels, table is [Foglio1$])WHERE Match(Numeri, 4, 5);


That should load from your excel file only records where field "Numeri" has values "4" or "5".

Hope that helps.

Anonymous
Not applicable
Author

Thanks Miguel

tresesco
MVP
MVP

hi,

here it unfortunately doesn't work as you hope. not very clear what you are trying to achieve. try to explain a bit more. and if you try to include a code in your post, follow

http://community.qlik.com/forums/p/15789/61380.aspx

with this your code would come well formatted.

Regards, tresesco

Anonymous
Not applicable
Author

Thanks Tresesco.
Let's see if I can do it.

I would like to fill the new table with the values assigned to "a" in the "for" statement, so if I say "for a=3 to 4" I should see the numbers 4 and 5 but in my table I see only the number 4, I can't fill the new table.

Thanks all for helping


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 a=3 to 4

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

[Lista Numeri e Lettere]:

load '$(varmyNumber)' as myNumberCharacter

AutoGenerate(1);

next


tresesco
MVP
MVP

so you have done it !

what you are trying using PEEK - telling the position from where (which of the pre-loaded records) to be picked. if this is what you want (positioned based values to pick), your code is probably to the right direction. if you are trying the exact numeric values (3 and 4) to pick then Miguel's suggestion is to be followed (provided the values are there in loaded data). i find one more possibilty you could attempt to : you might try to generate those values your own, in that case you have to rewrite the code somewhat like :

Load $(a) as MyNumberChar
Autogenerate (1);
Next


Probably PEEK would not be required.

Regards, tresesco

tresesco
MVP
MVP

sorry it came as a repeatation

Anonymous
Not applicable
Author

Thanks Tresesco

I will work on your suggestion

Antonio