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: 
venkatbza
Creator
Creator

Total function in script

Hello friends,

 

How to convert front end chart expression in back end script for below mentioned expression.

=Sales/Sum(TOTAL{1} Sales)

I have a material and sales fields now i have to create a field called  'percentage of total sales '. In the front end chat above expression is working fine, but i want this expression move to back end script. 

  OUTPUT column
MaterialSalessales/sum(sales)
11010/129 =0.77519
213 
320 
45 
515 
666 
Total129 

 

Thanks,

Venkat

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:
LOAD * INLINE [
    Material, Sales
    1, 10
    2, 13
    3, 20
    4, 5
    5, 15
    6, 66
];

Left Join (Table)
LOAD Sum(Sales) as TotalSales
Resident Table;

FinalTable:
LOAD *,
	 Sales/TotalSales as [percentage of total sales]
Resident Table;

DROP Table Table;

View solution in original post

3 Replies
sunny_talwar

Try this

Table:
LOAD * INLINE [
    Material, Sales
    1, 10
    2, 13
    3, 20
    4, 5
    5, 15
    6, 66
];

Left Join (Table)
LOAD Sum(Sales) as TotalSales
Resident Table;

FinalTable:
LOAD *,
	 Sales/TotalSales as [percentage of total sales]
Resident Table;

DROP Table Table;
venkatbza
Creator
Creator
Author

Excellent, it works fine

lu156478864
Partner - Contributor II
Partner - Contributor II

Hi @sunny_talwar ,

I need something similar, but I want to choose maximum value. This is my case: I have number of days- this is summarized value from script for each id sum(day)= Number of days and I need max value from it ( 362) in script.

lu156478864_0-1718118497801.png

 

Do you know how to deal with it?

Thanks