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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with sum() function and total

Hi,

I have a straight table with one dimension and one expression. Dimension is Company. Expression is shown here:

sum( (Payment *-1 / sum(TOTAL <Company>  Payment))*T)


With the example data, the straight table shows 2 rows, one for Company A and one for Company B.


I have problems with this part: sum(TOTAL <Company>  Payment). It calculates as a standalone expression, but as part of the expression above, it does not.

My expression calculates if I remove <Company>, but obviously then it does not calculate what I need. I want it to sum Payments over the dimension Company, so when calculating Company A, it sums up Payment only for company A, likewise with Company B.

Any help is greatly appreciated.

-Bjorn

Data:                                                                                        

CompanyPaymentT
A-22500      -0,003
A-22500      -0,499
A-22500      -1,003
A-22500      -1,501
A-22500      -2,005
A-22500      -2,501
A-22500      -3,005
A-22500      -3,501
B-1287142      -0,545
B-1287142      -1,548
B-1287142      -2,548
B-1287142      -3,548
B-1287142      -4,548
B-1287142      -5,551
B-1287142      -6,551
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You're nesting aggregation functions, but haven't applied the necessary aggr function. Try this expression:

sum( (Payment *-1 / aggr(sum(TOTAL <Company>  Payment),Company,Payment,T)*T)


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You're nesting aggregation functions, but haven't applied the necessary aggr function. Try this expression:

sum( (Payment *-1 / aggr(sum(TOTAL <Company>  Payment),Company,Payment,T)*T)


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

may be use by if and len functions. like this.It will work.

If(Len(company>0, .........................)

Not applicable
Author

Thanks Gysbert, it works.

-Bjorn