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: 
Not applicable

Issue with Expressing Total Margin in a Straight Table

Hi everyone,

I have a straight table which calulates gross margin per line.

When multiple lines are selected, it dispays the average % margin - 41%

How do you express the totals line to show the margin for the total value - in this case (Nett-Cost) / Nett, which should be 39%

Item£ List PriceNett Price£ Cost Margin %
A5,0002,0001,00050%
B3,0002,0001,00050%
C4,0003,0001,50050%
D2,0001,9001,50021%
E1,00050030040%
F50040020050%
G5,0001,00050050%
H5,0004,0002,90028%
I4,0001,5001,00033%
Total16,3009,90041%

The problem I am encountering is that I am not getting the total margin % at the bottom of all the individual margins. If I select 'Expression Total', it doesn't return any value but a '-'. If I select Sum of Rows, it literally adds up all the numbers which is not correct either. Selecting Average of Rows gives us the the Avg which is near to but still not correct Margin.

The formula for margin is : ''([Total Net Price]-[Total Cost])/[Total Net Price]'' where Total Net Price and Total Cost are also formulae. I heard that the Aggregation 'AGGR' function might be of help. So can anyone please guide me through AGGR function.

And if it can be done any other possible way, can anyone please guide me through that as well.

Thanks,

Zarar

1 Solution

Accepted Solutions
Gysbert_Wassenaar

See attached qvw.


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

Can you post the document you're working on? See Preparing examples for Upload - Reduction and Data Scrambling for how to do that safely.


talk is cheap, supply exceeds demand
JonnyPoole
Former Employee
Former Employee

If you use an aggregation function, it will know how to aggregate the details in the total line

replace:  '([Total Net Price]-[Total Cost])/[Total Net Price]

with  sum( [Total Net Price]-[Total Cost])  /  sum( [Total Net Price])

Anonymous
Not applicable
Author

see attached. it shows 39%.

Not applicable
Author

Hi Gysbert and others,
                                The file is attached in this comment. Can you please have a look and try to solve this issue.

Thanks,
Zarar

Gysbert_Wassenaar

See attached qvw.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert !
                 Thanks a lot for fixing this up. It is fixed now and I have been struggling with it for so long. Massively appreciate your help.

Regards
Zarar