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

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

Express Total Margin within 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 Nett 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%
Total 16,3009,90041%

Thanks,

Paul

8 Replies
maxgro
MVP
MVP

(sum([Nett Price]) - sum(Cost)) / sum([Nett Price])

a.jpg

Not applicable
Author

Thanks Massimo,

This works well, the only issue I have is that my Nett price is derived from a calculation of ‘List Price less Discounted Value’.

Do I need to include the calculated fields in the formula below, so something like...

(sum() - sum(Cost)) / sum()

Regards,

Paul

maxgro
MVP
MVP


I think

(sum([List Price] - [Discounted Value]) - sum(Cost)) / sum([List Price] - [Discounted Value])


another way

if you have a calculated field in your chart you can use it in the expressions in same chart using the label of that field




Not applicable
Author

Thanks for your response.

I have revisted my table but still have a few issues.

I have two input fields created, one for quantity and one for discount, The values for List Price and Cost are created by multiplying the input fields.

Should it be possible to see a calculated total margin, if input fields are contained within the expression?

Thanks,

Paul

timsaddler
Creator III
Creator III

Hello

Putting the calculation for margin value into the script may help the data to roll up correctly?

Not applicable
Author

Hello Everyone,
                      I am working with Paul on this tool as well. The problem we are encountering is that we are 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 Tim, can you please elaborate on what should be done in the script breifly.

Thanks,

Zarar

timsaddler
Creator III
Creator III

Put the calculation into the script instead of the Expression box. Then the roll up should work.

timsaddler
Creator III
Creator III

To explain better... here's an example from one of my scripts...

"Extended Price" as SalesExcLevy,

    
"Aggregate Levy" as AggLevy,

    
"Extended Price" + "Aggregate Levy" as SalesIncLevy,

    
"Std Cost Haulage" as 'StdCostOfHaulage',

    
"Split_Std_Cost_Of_Haulage" as 'SplitStdCostOfHaulage',

    
"Actual_Cost_of_Haulage" as 'ActCostOfHaulage',

     (
"Extended Price" + "Aggregate Levy") - "Std Cost Haulage" as StdExWorksSalesIncLevy,