Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
ArnoSoet
New Contributor II

Help needed for weighted average discount rate

Dear all,

I've been trying and trying to figure this out (I read some many threads about it as well) but I can't handle my data to reach my goal.

Here is the story with a table (the calculation is made with excel):

I need to calculate the weighted average discount rate for all articles

Article codePublic PriceQuantitySales
163FG357,50 €51.148,50 €
163FT370,83 €71.653,00 €
163FU404,17 €82.163,30 €
163FV537,50 €62.041,80 €
163FW562,50 €31.077,74 €

 

For each article, I've got public price, quantity and sales.

To get the discount rate I need to calculate the Average selling price as "Sales/Quantity"

Article codePublic PriceQuantitySalesAverage selling price
163FG357,50 €51.148,50 €229,70 €
163FT370,83 €71.653,00 €236,14 €
163FU404,17 €82.163,30 €270,41 €
163FV537,50 €62.041,80 €340,30 €
163FW562,50 €31.077,74 €359,25 €

 

Then I am able to calculate the discount rate for each article as "1-(Average selling price/Public Price)"

Article codePublic PriceQuantitySalesAverage selling priceDiscount rate
163FG357,50 €51.148,50 €229,70 €35,75%
163FT370,83 €71.653,00 €236,14 €36,32%
163FU404,17 €82.163,30 €270,41 €33,09%
163FV537,50 €62.041,80 €340,30 €36,69%
163FW562,50 €31.077,74 €359,25 €36,13%

 

Final step to get the "Weighted Discount rate" I do : 

=SUMPRODUCT(Discount rate;Quantity)/Sum(Quantity)

Weighted Discount rate35,39%

 

How would you do it within Qlik Sense? I am able to get a good discount for each article, when the total is not right !

That's my closest formula

((1-((Sum(Sales)/Sum(Quantity))/(Sum(Public Price))))*(Sum(Quantity)))/(Sum(Quantity))

I've enclosed the sample in a .xlsx file

Thank you in advance for your precisous help

1 Solution

Accepted Solutions

Re: Help needed for weighted average discount rate

Try this

=Sum(Aggr((1 - (Sum(Sales)/Sum(Quantity)/Sum([Public Price]))) * Sum(Quantity), [Article code]))
/
Sum(Quantity)
3 Replies

Re: Help needed for weighted average discount rate

Try this

=Sum(Aggr((1 - (Sum(Sales)/Sum(Quantity)/Sum([Public Price]))) * Sum(Quantity), [Article code]))
/
Sum(Quantity)
ArnoSoet
New Contributor II

Re: Help needed for weighted average discount rate

You're a god ! It's working.

Good news for the coming weekend 🙂

Do you know why my attemp was not working and that I needed to aggr on the article (as my table with filtered on article)? 

solution.PNG

 

Re: Help needed for weighted average discount rate

Because for the total row... you wanted to sum the multiplication of discount rate and quantity... you need to sum them otherwise the total row will also be done as any other row.