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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
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
Partner - Champion III
Partner - Champion III

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!