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

Help with max value

hi,

please I need help with getting the record  with max value "cycle" number for the combination of  ID, name in the below sample data.

IDnamecyclenumberplacedeptcountry
12a1n1place1dept1c1
12a2n1place2dept2c2
13a1n2place1dept2c1
13a2n2place2dept2c2
13a3n2place3dept3c4
14a1n3place4dept1c5

 

Required output

numberplacedeptcountry
n1place2dept2c2
n2place3dept3c4
n3place4dept1c5
1 Solution

Accepted Solutions
sunny_talwar

Script based

Table:
LOAD * INLINE [
    ID, name, cycle, number, place, dept, country
    12, a, 1, n1, place1, dept1, c1
    12, a, 2, n1, place2, dept2, c2
    13, a, 1, n2, place1, dept2, c1
    13, a, 2, n2, place2, dept2, c2
    13, a, 3, n2, place3, dept3, c4
    14, a, 1, n3, place4, dept1, c5
];

Right Join (Table)
LOAD number,
	 Max(cycle) as cycle
Resident Table
Group By number;

Will remove three of the unwanted rows from the database

View solution in original post

4 Replies
sunny_talwar

You need to do this in the script or a front end chart?

qvqfqlik
Creator
Creator
Author

anything works Sunny.

can you please give solution for both. Thankyou

sunny_talwar

Script based

Table:
LOAD * INLINE [
    ID, name, cycle, number, place, dept, country
    12, a, 1, n1, place1, dept1, c1
    12, a, 2, n1, place2, dept2, c2
    13, a, 1, n2, place1, dept2, c1
    13, a, 2, n2, place2, dept2, c2
    13, a, 3, n2, place3, dept3, c4
    14, a, 1, n3, place4, dept1, c5
];

Right Join (Table)
LOAD number,
	 Max(cycle) as cycle
Resident Table
Group By number;

Will remove three of the unwanted rows from the database

qvqfqlik
Creator
Creator
Author

Thankyou Sunny