Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
ThiagoOliv
Contributor
Contributor

How to get the number of sales of the best seller last year? FirstSortedValue and Count problem

Hello guys.

I'm new to this, and I'm trying hard to find an answer. Sorry if this is a common problem.

I have database like this: Seller, OrderID, YearSale

I'm tyring to display the number of sales of the best seller in the last year (of the filtered years, I need only the last one).

I came up with:

=count( { <YearSale={$(=num(max(YearSale)))}> + <FirstSortedValue(Seller, -Aggr(count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID), Seller)) > } distinct [OrderID])

I think I'm doing something simple in a hard way and honestly I don't know what's actually happening here.

I'd apreciate any help.

Labels (2)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

try below

 

= FirstSortedValue(count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID)  , -Aggr(count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID), Seller))

 

OR

 

=Max  (  AGGR( count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID) , Seller) )

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

2 Replies
vinieme12
Champion III
Champion III

try below

 

= FirstSortedValue(count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID)  , -Aggr(count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID), Seller))

 

OR

 

=Max  (  AGGR( count({$<YearSale={$(=Max(YearSale))}>} distinct OrderID) , Seller) )

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ThiagoOliv
Contributor
Contributor
Author

Many thanks! It worked