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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
nwilliams
Contributor
Contributor

Sum Field B dependant of DISTINCT value in Field A

Hi,

I have a requirement to sum the values in field B, but only require those where the value in column A is distinct.  Example:

The table below I would like the sum of column B = 289 and not = 415, hence it would remove the values in Red. Due to other data in the table, I can't remove the duplicates in the load script.  Has anyone got any ideas?

AB

11225

52
1122614
1122614
1122735
1122855
1122927
1122927
112306
1123185
1123185
1123215
1 Solution

Accepted Solutions
sunny_talwar

May be this

Sum(Aggr(B, A))

or

Sum(Aggr(Only(B), A))

or

Sum(Aggr(Avg(B), A))

or

Sum(Aggr(Sum(DISTINCT B), A))

View solution in original post

3 Replies
sunny_talwar

May be this

Sum(Aggr(B, A))

or

Sum(Aggr(Only(B), A))

or

Sum(Aggr(Avg(B), A))

or

Sum(Aggr(Sum(DISTINCT B), A))

pgriffiths
Creator
Creator

Sum(B) / Count(A)

Anonymous
Not applicable

Why can't you remove dups in the loads script?  Sunny's should work for you but cleaning up the data seems like it would be the best solution.