Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to store the values in a Table into a variable

TagName

Fill A Time

Fill B Time

Fill C Time

Tag A

06:00

Tag A

06:05

Tag A

06:09

Tag B

06:02

Tag B

06:03

Tag B

06:05

Tag B

06:06

Tag C

06:03

Tag C

06:05

Tag C

06:07

can anyone, please help me,  is there a way to get the last value for each field in the table..

To be clear, in the above situation, for each tag I will have lot of rows, but I am interested in the last row of each Tagname. Is there a way to get a last record for each value.

usually, we use Peak function to get the Filed value in a Table,we have to give the row number for accessing the value..

In my case, each tag will have more than one value and i will have no idea, which row number i should give in the peek function.

Is there a way to do it using peek function or do we have any other function..

please help me with this

Thank you

cleveranjoshallquist_nate

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

You can use TagName in place of TagName.

If your TimeStamp is recognized by QlikView, you can use your format, if your timestamp is not recogniced (you get your timestamp as a string), use this:

LET v$(vNameVar) = Time(Time#(Peek('MaxValue',$(i),'Max'),'YYYY-MM-DD hh:mm:ss'),'YYYY-MM-DD hh:mm:ss');


Regards!!

View solution in original post

32 Replies
MK_QSL
MVP
MVP

What is the value you want to store?
I mean what value of Tag A.. What value for Tag B and What for Tag C?

Anonymous
Not applicable
Author

Hi Ganesh,

Calculate max value for each group:

Max:

LOAD

     TagName,

     RangeMax(Max(Fill A Time),Max(Fill B Time),Max(Fill C Time)) as MaxValue

RESIDENT YourTable

GROUP BY TagName;

Then, you can create the vars you need with a for:

For i = 0 to NoOfRows(Max)-1

     LET vValue_$(i) = Peek('MaxValue',$(i),'Max');

Next i

Regards!!

avinashelite

You could try with the MAX() Function in the front end like

vAMax= max([Fill A Time])

vBMax= max([Fill B Time])


vCMax= max([Fill C Time])

Not applicable
Author

Hi Manish

Thanks for the quick reply

I like to store last value for each Tag.

I mean, Tag A : 06: 09

               Tag B : 06: 06

               Tag C : 06: 07

But, the above table is a sample table... I will not be sure that... Tag A will have only three values or anything like that..

But, I want the last value for each tag in the Table..

I hope, I am clear

MK_QSL
MVP
MVP

vTagA = Time(Max(Time#([Fill A Time],'hh:mm')),'hh:mm')

vTagB = Time(Max(Time#([Fill B Time],'hh:mm')),'hh:mm')

vTagC = Time(Max(Time#([Fill C Time],'hh:mm')),'hh:mm')

Not applicable
Author

HI Manish,

Thats really brilliant.. solution. But, I am getting an error because of my lack of knowledge in Time conversion, could you help me with that.. I tried like the following way

I am getting some  error  as " script line error"

actually i get the Time value in Timestamp format as "YYYY-MM-DD hh:mm:ss"..

That is the value of Fill A Time in the above Timestamp format..

I used these two expressions

LET vCurrentTime1=Time(Max(Time#([Fill A TIme],' YYYY-MM-DD hh:mm:ss')),'YYYY-MM-DD hh:mm:ss');

LET vCurrentTime1=Timestamp(Max([Fill A TIme]),'YYYY-MM-DD hh:mm:ss');

and also, i used your expressions as it is,  but i am getting the same error

Not applicable
Author

Hi Avinash

How are you??

When i use the above expression, I am getting Null value for the variable when i see in debug mode

but when i use the same expression in text, I am getting a value in float Format, as you know qlikview converts the date into a number format..

How to convert the time into a timestamp format of  'YYYY-MM-DD hh:mm:ss'

Thank you

Ganesh

Anonymous
Not applicable
Author

Hi Ganesh,

Have you seen my response?

You can create all variables that you need os script with a loop.

Regards!

Not applicable
Author

Hi Manuel

Sorry for the late reply.. i have seen this.. but, i am trying this now...

Thank you