Well the scenario goes like this: We have a Product Group column, Product Column and sales column.
We would like to sort this first based on sum of sales for product group and then for each product within that group. A product can appear in more than one group. And finally we want to do this in a Bar chart. So the ordering of the bars is by sales for product group and the ordering of groups within bars is by products sales.
So the idea was if we could get sum of Product group maybe we could use it to help in sorting bar graph.
if that's all you want to do...just load the table into qlik, create a bar chart with dimensions as product group and product and expression as sum(Sales). you can sort depending on the requirement in the Sort tab of object properties.
but if this has to be done on the script side which is always a good idea, use group by like the above posters suggested...