Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
thanhphongle
Creator II
Creator II

return the quantity of assets from the max sum(Price) from a category

Hello Community,

This is my database:

CategoryProductPrice
LaptopAsus Zen300
LaptopSony f12x400
LaptopApple Mac Pro800
PCAlienware Pro2000
PCHP Gaming X41500
MouseRazor Diamondback50
KeyboardLogitec Wireless30
MouseLogitec G560
HeadsetCreative GX 880

I want QV to return me quantity of assets considering the max sum(Price) of a Category.

In this case it should return me:

Category = PC and Quantity = 2

This is my expression which i m using. But somehow it is not working correctly.

Concat(DISTINCT {<Category = {"=Aggr(Sum(Price), Category) = Max(TOTAL Aggr(Sum(Price), Category))"}>} Categoy, ', ') & ' \n'

& Max(TOTAL Aggr(count(Category), Category))

Could anyone help me out here?

23 Replies
MK_QSL
MVP
MVP

What result you are looking for? if 409 is not correct?

MK_QSL
MVP
MVP

='Max Category-Quantity' & CHR(10) &

CONCAT({<Category = {"=RANK(SUM([Selling price]),4)=1"}>}DISTINCT Category,', ') & CHR(10) &

COUNT({<Category = {"=RANK(SUM([Selling price]),4)=1"}>}Category)

MK_QSL
MVP
MVP

or

='Max Category-Quantity' & CHR(10) &

CONCAT({<Category = {"=RANK(SUM({<Category>}[Selling price]),4)=1"}>}DISTINCT Category,', ') & CHR(10) &

COUNT({<Category = {"=RANK(SUM({<Category>}[Selling price]),4)=1"}>}Category)

thanhphongle
Creator II
Creator II
Author

I dont get it. In your attached file it is working. I exactly copied the expression into my real database with the same attributes. But it doesnt work there... I dont know why it still returns me quantity = 61 instead of 947. Is there anything what i have to consider in the database?

sunny_talwar

Won't know until I see it. Manish do you have suggestions?

thanhphongle
Creator II
Creator II
Author

I tried the expression of Manish as well. Same problem

MK_QSL
MVP
MVP

We need to see your real file... without looking into it, can't find out what's going wrong !

MK_QSL
MVP
MVP

Are you sure that the data structure is same in your real application compare to the data you have provided as sample file?

thanhphongle
Creator II
Creator II
Author

I attached a test database close to the main database with exactly the same problem. This file is locked

sunny_talwar

This still works:

Count({<Category = {"=Aggr(Sum([Selling price]), Category) = Max(TOTAL Aggr(Sum([Selling price]), Category))"}>}[Serial Number])


Capture.PNG