Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bvmike2001
Contributor III
Contributor III

sum on a field related to distinct values in another field

Hello,

how can i translate this sql query in a QV expression:

select sum(field_x)

     from (select distinct ID, field_x from table_y)

Basically i want to calculate an expression as a sum of data from a field but only for other distinct values in an ID filed.

Thanks!

3 Replies
tresesco
MVP
MVP

Probably I have not got you right, may be like this?

Straight table; dimension-ID, Expression: Sum(field_x). // if not this, would request to explain with an small example (table).

Gysbert_Wassenaar

If you have several records per ID with the same field_x value then you can get the sum of the distinct values by using the max or avg function first: sum(aggr(max(field_x),ID))


talk is cheap, supply exceeds demand
bvmike2001
Contributor III
Contributor III
Author

Thanks G. for the solution!