Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
souadouert
Specialist
Specialist

TOP MAX 2 CUSTOMER

HELLO 
HOW TO HAVE THE TOP TWO OF CUSTOMERS WHO HAVE MAX NUMBER OF SALES IN SCRIPT

GROUPCUSTOMERSALES µ
A1001
A1014
A1025
A1036
B10410
B105100
B10620
B10730
C108120
C109160
C110140
C111120
C112200
   
   
   
GROUPCUSTOMERSALES µ
A1036
A1025
B105100
B10730
C112200
C109160
Labels (1)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Key in ranking in script is to use sorting, i.e. using order by clause. Try something like:

Input:
LOAD GROUP, 
     CUSTOMER, 
     [SALES µ]
FROM
[https://community.qlik.com/t5/New-to-QlikView/TOP-MAX-2-CUSTOMER/td-p/1695653]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1) where RowNo()<13;


Sort:
Load GROUP,
	 CUSTOMER,
	 Sum([SALES µ]) as [SALES µ],
	 AutoNumber(RowNo(),GROUP) as Count
Resident Input 
		Group By GROUP, CUSTOMER 
		Order By GROUP, [SALES µ] desc;	

NoConcatenate	
Output:	
Load
    *
Resident Sort where Count<3;

Drop Table Sort, Input;

Capture.PNG

View solution in original post

1 Reply
tresesco
MVP
MVP

Key in ranking in script is to use sorting, i.e. using order by clause. Try something like:

Input:
LOAD GROUP, 
     CUSTOMER, 
     [SALES µ]
FROM
[https://community.qlik.com/t5/New-to-QlikView/TOP-MAX-2-CUSTOMER/td-p/1695653]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1) where RowNo()<13;


Sort:
Load GROUP,
	 CUSTOMER,
	 Sum([SALES µ]) as [SALES µ],
	 AutoNumber(RowNo(),GROUP) as Count
Resident Input 
		Group By GROUP, CUSTOMER 
		Order By GROUP, [SALES µ] desc;	

NoConcatenate	
Output:	
Load
    *
Resident Sort where Count<3;

Drop Table Sort, Input;

Capture.PNG

View solution in original post