Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
that_anonymous_guy
Contributor III
Contributor III

Calculate sum of a column based on a different column

I have a table which has values like this

A B
001 15
001 15
001 15
002 20
002 20
002 20
003 35
003 35
003 35

 

I want to have sum of B for different ids of A.Like for 001 we'll take 15, 20 for 002 and 35 for 003 and the final answer would be 70. I want to do this in from end.

 

Labels (7)
7 Replies
Ahidhar
Creator III
Creator III

something like this ?

Ahidhar_0-1704802537334.png

 

that_anonymous_guy
Contributor III
Contributor III
Author

yes..but this will not work. I just showed an example but there are multiple ids with lets say value 15 but here 15 will be considered just once but I want it to be considered for every id.

A B
001 15
001 15
001 15
002 20
002 20
002 20
003 35
003 35
003 35
004 15
004 15
004 15
Ahidhar
Creator III
Creator III

could you share the final output you are looking for

that_anonymous_guy
Contributor III
Contributor III
Author

85..in the new example table

Ahidhar
Creator III
Creator III

try this

tab:
load A,only(B) as B group by A;
load * inline
[
A, B
001, 15
001, 15
001, 15
002, 20
002, 20
002, 20
003, 35
003, 35
003, 35
004,15
004,15
004,15
];

Ahidhar_0-1704804251180.png

 

Parthiban
Creator
Creator

Try this one,

Sum(distinct B) in one new column

A Sum(distinct B)
Total 85
1 15
2 20
3 35
4 15
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If your Dimension is A, Distinct will apply per value of A. So 15 will be used for both 001 and 004.

-Rob