Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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!!
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?
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!!
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])
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
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')
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
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
Hi Ganesh,
Have you seen my response?
You can create all variables that you need os script with a loop.
Regards!
Hi Manuel
Sorry for the late reply.. i have seen this.. but, i am trying this now...
Thank you