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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Percentage Calculation

Hi,

Please could somebody help me with a percentage calculation?

I am busy with What If analysis and Input boxes and have the below scenario:

I have 4 products with a Sales Price. The user is allowed to enter a Discount% into an Input box. I then calculate the Fee after Discount. Each of these products have a Payback (Cost of Sale). I then calculate the Margin which is the Sales Price - Discount% - Payback.  After this I calculate the Margin%.  It calculates the Margin% per product correctly, but my problem is with the Total Margin% which is the 10% in red. It should actually be the 31% in green.  It looks like it does the 20% Discount on the Total Sales Price and calculates the Margin% from there.  Just below the table you can see the calculations I use.  What should I change so it would use the Total Margin (4300.2) / Total Payback (13860) to get the 31%

ProductSales PriceDiscount%Fee after DiscountPaybackMarginMargin%Header
TOTAL1911618160.2138604300.210%31%
A477947793465131438%
B477947793465131438%
C4779203823.23465358.210%
D477947793465131438%

Sales Price = sum(ExchangeFee*vSalesPctChange)

Discount% = InputSum(UnitPriceInputDiscount)

Fee after Discount = sum(ExchangeFee*vSalesPctChange)*(1-(Discount%/100))

Payback = sum(PaybackAmount*vCostPctChange)

Margin = [Fee after Discount] - sum(PaybackAmount*vCostPctChange)

Margin% = [Margin]/sum(PaybackAmount*vCostPctChange)

Thanks

Antoinette

Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

If you are using a Straight Table, you can try to change the Total Mode for the Margin% to Average. You can find the Total Mode by going to the Expressions tab, selecting Margin% and changing the Total Mode.

TotalMode.JPG.jpg

View solution in original post

8 Replies
Not applicable
Author

what is PaybackAmount and vCostPctChange

why dont you just use [Margin]/[Payback]

Greg_Williams
Former Employee
Former Employee

One can use Column(1) / Column(2) ... adding some more logic might be required for your exact calculation...but easy way to create a calculation. Otherwise - perhaps using some set analysis might be required?

There is a "Relative" option in the Expression tab in the chart properties that might be of use to you.

Not applicable
Author

I tried [Margin]/[Payback] and it stills gives me the 10%

Not applicable
Author

Hi,

I've tried Column(1)/Column(2) and the relative option also doesn't work in my scenario.

Can you maybe give me an example of the set analysis?

Greg_Williams
Former Employee
Former Employee

Have you played with the Aggregation on the expression in the expression's tab? "Total Mode"

Set Analysis: syntaxes, examples

Not applicable
Author

If you are using a Straight Table, you can try to change the Total Mode for the Margin% to Average. You can find the Total Mode by going to the Expressions tab, selecting Margin% and changing the Total Mode.

TotalMode.JPG.jpg

Not applicable
Author

Hi,

Thanks for the useful doc.  I will work through it.

Not applicable
Author

Thank you for this.  It looks like it is working.