Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting last entry of a groups within a pivot table

Hi I have a pivot table showing employees and their clocked in/out status along with the time that they clocked in / out

I only want to show the last transaction for each employee rather than all of the clockings for that day.

I have calculated a rank value to try to help but can't seem to get beyond this.

Simply I have got a table with Employee, Time, Rank

e.g.

Fred, 09:00, In, 1

Fred 09:55,Out 2

Jo, 08:55,In,1

Bert, 08:40,In,1

Bert, 12:40,Out,2

Bert, 14:40,In,3

I want to only show the entries in bold

Thanks in advance for any help

6 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can use the firstsortedvalue for this. You can use Type and Name as dimensions and as expressions:

Time: firstsortedvalue(Time, -Rank)

Rank: max(Rank)

In/Out: firstsortedvalue(In_Out_Field, -Rank)

see attached qvw.


talk is cheap, supply exceeds demand
Not applicable
Author

Attached the QV file for perusal

Not applicable
Author

Thanks for that, I've added an expression

firstsortedvalue(EMPLNO, -CLCKTM) but it is  returning a blank

Also tried


firstsortedvalue(EMPLNO, -Rank) with the same result


Not applicable
Author

Mea Culpa, I misunderstood the use of the Dimension for sorting.

All working now

Thnks Gysbert

Not applicable
Author

see attachement

test:

LOAD * INLINE [

    employee, time, status, rank

    Fred, 09:00, In, 1

    Fred, 09:55, Out, 2

    Jo, 08:55, In, 1

    Bert, 08:40, In, 1

    Bert, 12:40, Out, 2

    Bert, 14:40, In, 3

];

LOAD   

      employee as employeenew,

      max(time(time,'hh:mm')) as maxtime ,

      FirstSortedValue(status,-time(time,'hh:mm')) as statusnew,

      FirstSortedValue(rank,-time(time,'hh:mm')) as ranknew

      Resident test Group by employee;

DROP Table test;  

then take a pivote/straight table--

dimension= employeenew

expression1=maxtime

expression2=statusnew

expression3=ranknew

then in sort tab-->select load order

then output like this

employeenewmaxtimestatusnewranknew
---
Fred09:55Out2
Jo08:55In1
Bert14:40In3
er_mohit
Master II
Master II

see the attached file