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

Average of Top 2 sales people per product

I have a table that looks somthing like this:

ProductSalesSalesperson
A100Peter
A200Peter
A300Paul
A700Paul
A10Alex
A20Alex
B10Peter
B20Peter
B300Paul
B300Paul
B700Alex
B450Alex

 

So in this case Peter and Paul sold the most for product A and Alex and Paul for product B.

So what I want as a result would be

ProduktAverage of Top 2 salespeople
A325
B437,5

 

For the real data I build this expression but I just get a 0.

 

Sum(aggr(
    	sum(Sales),Product,
        If(Aggr(Rank(Aggr(Sum([Sales]), [Product], [Salesperson]), 3, 1), [Product], [Salesperson]) <= 11, [Salesperson])
        )
)

 

In this case it's for the top 10 salespeople.

Any help is appreciated! 🙂

Labels (3)
1 Reply
fzalexanderjohn
Creator
Creator
Author

Anybody maybe?