Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

yamananalytic
Contributor II

usage of Peek Function

Hi guys,

i have these data

p2.png

I want to fetch  the first value "yaman" by giving the value of key which "Person"

How can i do it using Qlik sense script.

swuehl

stalwar1

diego.a.barboza

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: usage of Peek Function

Sort your table in ascending/descending order of your field ID and then use Peek() function

11 Replies
MVP
MVP

Re: usage of Peek Function

I want to fetch  the first value "yaman" by giving the value of key which "Person"

Not sure I understand this statement of yours?

antoniotiman
Honored Contributor III

Re: usage of Peek Function

May be like this

LOAD Key,FirstValue(Value) as Value
From
Table
Group By Key;

An example :

LOAD Key,FirstValue(Value) as Value Inline [
Key,attribute,Value
Person,Name,Yaman
Person,Surname,Alsaadi
Person,Age,30
Person,Salary,1000
Car,Engine,Crome
Car,Model,2010
Car,Color,Red
]
Group By Key;

sumanta12
Contributor II

Re: usage of Peek Function

TABLE:

LOAD * INLINE [

KEY,ATTRIBUTE,VALUE

PERSON,NAME,YAMAN

PERSON,SURNAME,ALSAADI

PERSON,AGE,30

PERSON,SALARY,1000

CAR,ENGINE,CROME

CAR,MODEL,2010

CAR,COLOR,RED

];

LET vName=PEEK('VALUE',0,'TABLE');

yamananalytic
Contributor II

Re: usage of Peek Function

i mean i  have the value "Person" and i want to know the value of the same row under Value field

MVP
MVP

Re: usage of Peek Function

Is antoniotiman‌ solution not working for you?

yamananalytic
Contributor II

Re: usage of Peek Function

it is working just for previous example but if i do not know in which row the key is how can determine the middle parameter in peek function which is the previous example 0

yamananalytic
Contributor II

Re: usage of Peek Function

MVP
MVP

Re: usage of Peek Function

What do you mean when you say that you don't know which row the key is? I am not sure I understand the whole logic you are trying to implement here

yamananalytic
Contributor II

Re: usage of Peek Function

from the following data :

p2.png

if i have the first ID whixh is 00000000-0000-0000-0000-000000000000 and i want to get the value of the Name which is "Battle"

How can i do it using Peek function but if i do not know the location of this record (only in this example the record in the first row) . i now only the value of ID

so what will be the middle parameter of the peek function !!!