Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ClareChinonye
Contributor III
Contributor III

Sum

Hi, please help.

I'm trying to sum the LTU_QTY for Each LTU_SOURCE_REF number to get an aggregate. Just like a select sum(LTU_QTY) In SQL 

 

this is an example of my script, but i keep getting errors

 

Example

LIB CONNECT TO 'ABC_LIVE SFDC';

LOAD LTU_TYPE,
LTU_SOURCE_REF,
LTU_QTY;

[UDEF_VIEW_ABC_Ltu_view]:
SELECT "LTU_TYPE",
"LTU_SOURCE_REF",
"Sum(LTU_QTY)"
FROM SFCapture.dbo."UDEF_VIEW_ABC_Ltu_view" WHERE LTU_TYPE = 20 AND (LTU_SOURCE_REF LIKE '0%' OR LTU_SOURCE_REF LIKE '1%');

Labels (1)
5 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

You need to assign a field name to the calculated sum. 

Try this:

Sum("LTU_QTY") as "LTU_QTY"

ClareChinonye
Contributor III
Contributor III
Author

I tried, it didn't work

MatheusC
Specialist II
Specialist II

@ClareChinonye 
As you are using an aggregation function, try inserting the Group by clause into your script for the dimensions.

FROM SFCapture.dbo."UDEF_VIEW_ABC_Ltu_view" ONDE LTU_TYPE = 20 AND (LTU_SOURCE_REF LIKE '0%' OU LTU_SOURCE_REF LIKE '1%') Group by "LTU_TYPE",
"LTU_SOURCE_REF"
;

Regarts, Matheus



Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
ClareChinonye
Contributor III
Contributor III
Author

I tried that also,still error

MatheusC
Specialist II
Specialist II

Maybe it's because I didn't rename the aggregation field

[UDEF_VIEW_ABC_Ltu_view]:
SELECT
"LTU_TYPE",
"LTU_SOURCE_REF",
“Sum(LTU_QTY)” as “LTU_QTY”
FROM SFCapture.dbo."UDEF_VIEW_ABC_Ltu_view" WHERE LTU_TYPE = 20 AND (LTU_SOURCE_REF LIKE '0%' OR LTU_SOURCE_REF LIKE '1%') Group by "LTU_TYPE","LTU_SOURCE_REF";


Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!