Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum and difference of two columns

Hello everyone,

I'm trying to sum two column totals. What I need is a new column,where I will show sum of two previous columns.

Example:

Col1:  Apples=5

Col2:  Grapes=10

I want a new column as Fruits=15

Similar way I want the difference of those two columns

Thank You

5 Replies
Not applicable
Author

load col1+col2 as fruits, col1, col2;

load

  ....

.....

;

saumyashah90
Specialist
Specialist


Can you paste the table for some values?

Sum=Count(Col1)+Count(Col2)

Diff=Count(Col1)-Count(Col2) or viceversa

tresesco
MVP
MVP

RangeSum(Col1, Col2) as Fruits

Or, simply

Col1+Col2 as Fruit             // this won't work if there are null values

Alt(Col1,0)-Alt(Col2,0) as Difference

Or, simply

Col1-Col2 as Difference            // this won't work if there are null values

sujeetsingh
Master III
Master III

Do you need to represent this in UI or you want this for script

For UI you can easily do this by Pivot table

its_anandrjs

Hi,

In chart you have do do like

Assume Column One is

Col1:  Apples=5

And Column two is

Col2:  Grapes=10

Column(1) +  Column(2)

And you need this in the expression or load script.

If load script then

LOAD Apples,Grapes,Apples+Grapes as Sum;

LOAD * Inline

[

Apples,Grapes

5,10

];

Regards
Anand