Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 |
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 ;
Use the TOTAL keyword
=SUM(TOTAL <id> value2)
https://community.qlik.com/t5/QlikView-App-Dev/Keywords-TOTAL-ALL-DISTINCT/td-p/143514