Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
grant_S
Contributor
Contributor

how to sum field value in script

here is the data:

 

t1:
load * inline [
name,money
Grant,22
Joey,45
Bob,100
Grant,30
];


let GrantMonty = ?????    ====>>>>   how to sum Grant's money and put it into variable 'GrantMoney' ?

 

1 Solution

Accepted Solutions
Patricia_Silva
Specialist II
Specialist II

Hello @grant_S, I think you could use the function SUM in that way: https://help.qlik.com/en-US/sense/May2021/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunc...

 

It is just an example but then you can apply it to your script:

 

Temp:

LOAD * inline [

Customer|Product|OrderNumber|UnitSales|CustomerID

Astrida|AA|1|10|1

Astrida|AA|7|18|1

Astrida|BB|4|9|1

Astrida|CC|6|2|1

Betacab|AA|5|4|2

Betacab|BB|2|5|2

Betacab|DD

Canutility|DD|3|8

Canutility|CC

] (delimiter is '|');

Sum:

LOAD Customer, Sum(UnitSales) as MySum Resident Temp Group By Customer;

 

Hope this helps 🙂

Help users find answers! Don't forget to mark a correct resolution 🙂

View solution in original post

3 Replies
Patricia_Silva
Specialist II
Specialist II

Hello @grant_S, I think you could use the function SUM in that way: https://help.qlik.com/en-US/sense/May2021/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunc...

 

It is just an example but then you can apply it to your script:

 

Temp:

LOAD * inline [

Customer|Product|OrderNumber|UnitSales|CustomerID

Astrida|AA|1|10|1

Astrida|AA|7|18|1

Astrida|BB|4|9|1

Astrida|CC|6|2|1

Betacab|AA|5|4|2

Betacab|BB|2|5|2

Betacab|DD

Canutility|DD|3|8

Canutility|CC

] (delimiter is '|');

Sum:

LOAD Customer, Sum(UnitSales) as MySum Resident Temp Group By Customer;

 

Hope this helps 🙂

Help users find answers! Don't forget to mark a correct resolution 🙂
Kushal_Chawda

@grant_S  why would you like to put individual money into individual variable?

grant_S
Contributor
Contributor
Author

just want to have the script short in some special cases.

use load sum it's ok but may take more steps,