Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
blpetosa
Contributor III
Contributor III

Sum with FirstSortedValue

Hello Everyone,

Here is a sample of my data set:

Estimate_Number          Quote_number           Description          Estimate

368                                         0                              Hotel                   1000

368                                         0                              Plane                    500

368                                         0                              Food                     300

368                                         1                              Plane                    400

368                                         1                              Food                     400

368                                         1                              Car                       500     

I had a similar question a couple of weeks back where I wanted to get the value of Description where the Quote_Number was at its max value. Sunny correctly helped me out with this:

Sum(Aggr(FirstSortedValue(Estimate, -Quote_number  ), Description ))

I didn't realize that we are only concerned with the Descriptions where the Quote_Number is at its max value. So in this example, I don't want the Hotel estimate to be included, and only want the sum (1300) of Plane. Food, and Car where Quote_Number is 1 (Max).

I appreciate any help with this,

Ben

Labels (1)
1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

Where do you want this to be displayed? You can try like

= Sum({<Quote_number = {"= Max(Quote_number)"} >} Estimate)

OR

= Sum(Aggr(Sum({<Quote_number = {"= Max(Quote_number)"} >} Estimate), Description))

View solution in original post

2 Replies
vishsaggi
Champion III
Champion III

Where do you want this to be displayed? You can try like

= Sum({<Quote_number = {"= Max(Quote_number)"} >} Estimate)

OR

= Sum(Aggr(Sum({<Quote_number = {"= Max(Quote_number)"} >} Estimate), Description))

blpetosa
Contributor III
Contributor III
Author

Thank you Vishwarath! I ended up using your second option, and it works perfectly.