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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Nagaraju_KCS
Specialist III
Specialist III

Latest record

Hi, how to calculate latest record

mat      Item       Year       Month     Toal

AAAA   A01          2012     8               50

AAAA   A01          2012     11             12

AAAA   A01          2012     12               21

MMM   A04         2013      9               90

MMM   A04          2013     8               50

I want to return

AAA    A01    2012     12   21

MMM   A04    2013     9     90

Thanks in Advance

Labels (1)
3 Replies
tresB
Champion III
Champion III

May be like attached sample?

senpradip007
Specialist III
Specialist III

try this:

 

A:

LOAD * Inline [

mat, Item, Year, Month, Toal

AAAA, A01, 2012, 8, 50

AAAA, A01, 2012, 11, 12

AAAA, A01, 2012, 12, 21

MMM, A04, 2013, 9, 90

MMM, A04, 2013, 8, 50

]
;

Inner Join(A)

LOAD
Max(Year) AS YearMaxim,
Max(Month) As Month

Resident A
Group By mat;

Not applicable

hi

this is according to your requirement.

tab1:

LOAD * INLINE [

    mat, Item, Year, Month, Toal

    AAAA, A01, 2012, 8, 50

    AAAA, A01, 2012, 11, 12

    AAAA, A01, 2012, 12, 21

    MMM, A04, 2013, 9, 90

    MMM, A04, 2013, 8, 50

];

output:

load

mat as mat_new,

Item as Item_new,

Year as Year_new,

max(Month) as Month_new,

FirstSortedValue(Toal,-Month) as Total_new

Resident tab1

Group by mat,Item,Year;

DROP Table tab1;