Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Peek Function

Hello together,

I have the following table:

Datenpunkt_ID

DatumUhrzeitM_WertTextB_Wert
9782016-12-07 18:04:00.00014,1928814.19287662,43
9782016-12-09 08:30:00.00014,1868314.18682662,39
9782016-12-09 16:06:00.00014,187514.18750062,4
9782016-12-0920:01:00.00014,1868314.18682662,39
9782016-12-10 08:02:00.00014,1881714.18817162,4
9782016-12-10 18:04:00.00014,1895114.18951462,41

I woud like to show with the peek function the last upload value from B_Wert:

I tried with the function:
Peek('B_Wert',-1,'MeasurementValues')

But I get allways an error that the function is incorrect.

In this example is the last upload value the 62,41 from Date 2016-12-10.

Any solutions?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Since there are multiple values per date, you need to use a timestamp to define the last value.

Create a timestamp value in the script from date and time, or maybe

=FirstSortedValue(DISTINCT B_Wert, -(Datum+Uhrzeit) )

or

=FirstSortedValue(DISTINCT B_Wert, - TimeStamp#(Datum & Uhrzeit,'YYYY-MM-DDhh:mm:ss.fff') )


edit: and you need to either select an ID or use the expression with an ID dimension.

View solution in original post

8 Replies
vinieme12
Champion III
Champion III

in a Straight table try

FirstSortedValue(B_Wert,-Num(Datum))

or

Max(  {<Datum = {"$(=Date(Max(Total <Datenpunkt_ID> Datum)),'YYYY-MM-DD')"}>}B_Wert)

Peek is a scripting function

https://help.qlik.com/en-US/qlikview/12.1/Subsystems/Client/Content/Scripting/InterRecordFunctions/P...

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Karthik3
Creator III
Creator III

It depends on where you are putting the Peek function. Try the firstsortedvalue function.

Not applicable
Author

I have more than this one table conected with a SQL server. So I have more Datenpunkt_ID then I show you in the example. I set a filter to Datenpunkt_ID.

krishna20
Specialist II
Specialist II

i did same scenario using first sorted value

FirstSortedValue(B_Wert,-Datum)  you can try this it works

Not applicable
Author

I tried with a simple KPI but it doesn´t work.

Can I use a KPI?

swuehl
MVP
MVP

Since there are multiple values per date, you need to use a timestamp to define the last value.

Create a timestamp value in the script from date and time, or maybe

=FirstSortedValue(DISTINCT B_Wert, -(Datum+Uhrzeit) )

or

=FirstSortedValue(DISTINCT B_Wert, - TimeStamp#(Datum & Uhrzeit,'YYYY-MM-DDhh:mm:ss.fff') )


edit: and you need to either select an ID or use the expression with an ID dimension.

vinieme12
Champion III
Champion III

have you tried with max?

or with timestamp as Stefan has suggested?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

Thank you Stefan

The function works, first I select an ID


=FirstSortedValue(DISTINCT B_Wert, -(Datum+Uhrzeit) )

with the other function it doesn't work

=FirstSortedValue(DISTINCT B_Wert, - TimeStamp#(Datum & Uhrzeit,'YYYY-MM-DDhh:mm:ss.fff') )