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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculating Total According to Unique Key

Hi All,

I need help with creating an expression to sum values for a given field with the ability to filter according to a distinct key value to avoid double counting.

For example

KeySale
Key1500
Key1500
Key21000
Key21000
Key31500
Key31500
Key3

1500

I want to calculate distinct Key1 + Key2 + Key3 and arrive at 3000 as the total instead of 7500.

Your help will be greatly appreciated

p.s. if you're wondering the kind of data set that has this set-up, it is list of flights transporting cargo under a unique contractual agreement, where the contractual agreement is the Master Air Waybill.

1 Reply
sunny_talwar

Try this

Sum(Aggr(Sale, Key))

or this

Sum(Aggr(Avg(Sale), Key))

or

Sum(Aggr(Sum(DISTINCT Sale), Key))