Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Not applicable

load col1+col2 as fruits, col1, col2;

load

  ....

.....

;

Highlighted
Specialist
Specialist


Can you paste the table for some values?

Sum=Count(Col1)+Count(Col2)

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

Highlighted
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

Highlighted
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

Highlighted

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