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: 
Kashia1122
Contributor II
Contributor II

Sum

Hello,

I need to calculate the sum of the value2 for the unique id field.

id id2 value value2
A 1A 10 30
A 2A 20
B 1B 10 10
C 1C 11 37
C 2C 12
C 3C 14
D 1D 20 20

 

I used: sum(aggr(Sum( distinct {<id>} value2),id)), but in the lines I have 0(column "sum value2"). I want to present the data as in column "sum"

id id2 value sum value2 sum
      97 97
A 1A 10 30 30
A 2A 20 0 30
B 1B 10 10 10
C 1C 11 37 37
C 2C 12 0 37
C 3C 14 0 37
D 1D 20 20 20

 

Labels (2)
2 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @Kashia1122 ,

Please modify the script as below to get desired output.

data:
load * inline
[id,id2,value
A,1A,10
A,2A,20
B,1B,10
C,1C,11
C,2C,12
C,3C,14
D,1D,20]
;

new:
Load
id,
sum(value)as newvalue
Resident data
group by id ;

abhijitnalekar_0-1655404797190.png

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
vinieme12
Champion III
Champion III

Use the TOTAL keyword

 

=SUM(TOTAL <id> value2)

 

https://community.qlik.com/t5/QlikView-App-Dev/Keywords-TOTAL-ALL-DISTINCT/td-p/143514

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.