Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
madmax88
Creator II
Creator II

Adding multiple fields in Data load Editor

Hi all,

 

I have a question about adding up 2 or more fields in the data load Editor. E.G

 

Table:

ID,

Sales_Region_A,

Sales_Region_B

From XYZ

 

Now I need the Sum of total Sales  in the script by ID. In the Front End it must be already calculated.

Is there any way? I already tried by just adding up, but it doesn't work-->

ID,

Sales_Region_A,
Sales_Region_B

Sales_Region_A + Sales_Region_B as Total_Sales

From XYZ.

Thanks

1 Solution

Accepted Solutions
rubenmarin
MVP
MVP

Maybe it's because some have null values, and and addtion using null values returns null, maybe with RangeSum():
ID,
Sales_Region_A,
Sales_Region_B
RangeSum(Sales_Region_A, Sales_Region_B) as Total_Sales
From XYZ.

If using a group by as proposed above all fields must be in the group by clause or in an aggregation function or it will return an error:
FinalTable:
Load
ID,
Sum(Sales_Region_A) as Sales_Region_A,
Sum(Sales_Region_B) as Sales_Region_B,
Sum(Sales_Region_A + Sales_Region_B) as Total_Sales
Resident Table
Group by ID

View solution in original post

3 Replies
chandrasjr2
Partner - Contributor II
Partner - Contributor II

Hi,

Try the following code.

 

FinalTable:

Load 

ID,

Sales_Region_A,
Sales_Region_B

Sum(Sales_Region_A + Sales_Region_B) as Total_Sales

Resident Table

Group by ID

;

Drop Table Table;

rubenmarin
MVP
MVP

Maybe it's because some have null values, and and addtion using null values returns null, maybe with RangeSum():
ID,
Sales_Region_A,
Sales_Region_B
RangeSum(Sales_Region_A, Sales_Region_B) as Total_Sales
From XYZ.

If using a group by as proposed above all fields must be in the group by clause or in an aggregation function or it will return an error:
FinalTable:
Load
ID,
Sum(Sales_Region_A) as Sales_Region_A,
Sum(Sales_Region_B) as Sales_Region_B,
Sum(Sales_Region_A + Sales_Region_B) as Total_Sales
Resident Table
Group by ID
madmax88
Creator II
Creator II
Author

thx, with rangesum it works! Think it's because of the null values