Weighted Average in Excel, 2 different results - excel

Hi all,
I have something that I cannot explain.
Here is an explanation of the table
Weight
Price Increase in %
Old Price
New Price = ( Old Price * Price Increase ) + Old Price
Total Old Price = Old Price * Weight
Total New Price = New Price * Weight
When using SumProduct to calculate the weighted average I get
=SUMPRODUCT(A2:A6,B2:B6)/SUM(A2:A6) = 16.1072%
But a Finance guy told me that was wrong that I needed to calculate it like this
=SUM(F2:F6)/SUM(E2:E6)-1 = 16.2465%
1 - Why is it giving different results
2 - Who is right
Anyone able to shed some light on this would be greatly appreciated !

Related

DAX. Problem with subtotals and grand totals

hope you are doing well and can help solve this puzzle in DAX for PowerBI and PowerPivot.
I'm having troubles with my measure in the subtotals and grand totals. My scene is the following:
I have 3 tables (I share a link below with a test file so you can see it and work there :robothappy:):
1) "Data" (where every register is a sold ticket from a bus company);
2) "Km" (where I have every possible track that the bus can do with their respective kilometer). Related to "Data";
3) and a "Calendar". Related to "Data".
In "Data" I have all the tickets sold from a period with their price, the track that the passenger bought and the departure time of that track.
Each track can have more than 1 departure time (we can call it a service) but only have a specific lenght in kilometers (their kilometers are specified in the "Km" table). 
Basically what I need is to calculate the revenue per kilometer for each service in a period (year, month, day).
The calculation should be, basically:
Sum of [Price] (each ticket sold in the period) / Sum of [Km] (of the period considerating the services with their respective kilometers)
I managed to calculate it for the day granularity with the following logic and measures:
Revenue = SUM(Data[Price])
Unique dates = DISTINCTCOUNT(Data[Date])
Revenue/Km = DIVIDE([Revenue]; SUM(Km[Km])*[Unique dates]; 0)
I created [Unique dates] to calculate it because I tried to managed the subtotals of track granularity taking into account that you can have more than 1 day with services within the period. For example:
For "Track 1" we have registered:
1 service on monday (lunes) at 5:00am.
Revenue = $1.140.
Km = 115.
Tickets = 6.
Revenue/Km = 1.140/115 = 9,91.
1 service on tuesday (martes) at 5:00am.
Revenue = $67.
Km = 115.
Tickets = 2.
Revenue/Km = 67/115 = 0,58.
"Subtotal Track 1" should be:
Revenue = 1.140 + 67 = 1.207.
Km = 115 + 115 = 230.
Tickets = 6 + 2 = 8.
Revenue/Km = 1.207/230 = 5,25.
So at that instance someone can think my formula worked, but the problem you can see it when I have more than 1 service per day, for example for Track 3. And also this impact in the grand total of march (marzo).
I understand that the problem is to calculate the correct kilometers for each track in each period. If you check the column "Sum[Km]" is also wrong.
Here is a table (excel file to download - tab "Goal") with the values that should appear: 
[goal] https://drive.google.com/file/d/1PMrc-IUnTz0354Ko6q3ZvkxEcnns1RFM/view?usp=sharing
[pbix sample file] https://drive.google.com/file/d/14NBM9a_Frib55fvL-2ybVMhxGXN5Vkf-/view?usp=sharing
Hope you can understand my problem. If you need more details please let me know.
Thank you very much in advance!!!
Andy.-
Delete "Sum of Km" - you should always write DAX measures instead.
Create a new measure for the km traveled:
Total Km =
SUMX (
SUMMARIZE (
Data,
Data[Track],
Data[Date],
Data[Time],
"Total_km", DISTINCT ( Data[Kilometers Column] )
),
[Total_km]
)
Then, change [Revenue/Km] measure:
Revenue/Km = DIVIDE([Revenue], [Total Km])
Result:
The measure correctly calculates km on both subtotal and total levels.
The way it works:
First, we use SUMMARIZE to group records by trips (where trip is a unique combination of track, date and time). Then, we add a column to the summary that contains km for each trip. Finally, we use SUMX to iterate the summary record by record, and sum up trip distances.
The solution should work, although I would recommend to give more thoughts to the data model design. You need to build a better star schema, or DAX will continue to be challenging. For example, I'd consider adding something like "Trip Id" to each record - it will be much easier to iterate over such ids instead of grouping records all the time. Also, more descriptive names can help make DAX clean (names like km[km] look a bit strange :)

Excel Formula, To Calcuate a maximum Weight based off a desired minimum profit (GP%)

So I am working on a spreadsheet for a Butchery I manage and have run into a problem.
First off back story: We do $20 packs for certain bulk products that have a min/max weight range.
The Goal is to be able to put in this spreadsheet the desired minimum GP% and from that get a maximum weight based off that minimum profit margin.
For example a Beef Steak that Costs $17.50 p/kilo Would be minimum of 680g (at a GP% of 30.30%) and a maximum weight of 790g (at a GP% of 20.50%)
I have been 'googling' all day, and banging my head on my desk (as well as experimenting with different formula's) I am starting to think I may have to resort to programming a macro to perform this but I would prefer to be able to achieve in a formula on the cell that way I can copy-paste easily down the spreadsheet.
If anyone has a solution or can put me on the right track would be Awesome.
I think the formula you are looking for is :
your selling price (=20$) / your mark up on cost
where your mark up is :
your cost per kilo / (1- your margin)
So for 20% expected GP it gives :
= 20 / (17.5 / (1-0.2))
= 20 / 21.875
= 0.914... kilos
Balance is then :
Revenue = 20$
Cost = 0.914 * 17.5 = 16
Margin = 4
Margin % = 20

Excel formula for reverse percentage calculation

I have a calculation which I am unable to crack.
Lets say my Cost Price is 300. I want to sell the item at No Profit or No Loss. My total commission/expenses will be 30%. So it means i need to sell the item at 390.
But if I do 390 - 30% = 273.
How can I see the item, so that if I minus 30% to it. My Revenue will still be 300.
the formula you want is
=300/0.7
or
=300/(1-30%)
basically it is 300= x*(1-.30) where the (1-.30) is the amount that wants to be kept after the commision of 30%. Solving for x we get the above formula.
You want Sell Price - 30% Sell Price = Cost Price.
Combining the left two, you have 70% Sell Price = Cost Price.
Divide both sides by 70% and you get Sell Price = (1/0.7) Cost Price.
The fraction 1/0.7 is approximately 1.42857.
I was looking for a similar equation/formula, but then I built it in Excel.
So if you have, say, an item with
CostPrice = 200
Then you add a ProfitMargin = 20% so the
SellPrice = 200 + 20% = 240
Then the reverse equation for this will be
CostPrice = ( SellingPrice * 100 ) / ( ProfitMargin + 100 )
// In your case it should be
CostPrice = ( 240 * 100 ) / ( 20 + 100 )
= 200
Or Simply do the following:
CostPrice = SellingPrice / 1.2 = 240 / 1.2 = 200 <-- This will reduce the added 20%
I was looking for the same thing. None of the people here seemed to understand exactly what you were going for.
Here is the formula I used to get 300 as the answer.
=390/(1+30%)

Excel Function to Determine Optimal Price

I need help creating an Excel function that will determine the optimal price-point for a product, given the required profit margin.
NET MARGIN = (PROFIT / PRICE) = 30%
PRICE = (COGS + Fixed Costs + Variable Costs)
COGS = $5.00
FIXED = $3.00
VARIABLE = (15% * PRICE)
The problem that I can't get my head around is that as the price goes up, the variable costs go up as well. So how do I automate the product pricing for a required margin of 30%?
Any help is appreciated.

how Calculate Margin in GP

I want to Calculate profit margin from Dynamics GP Database.
Which fields or table been used. and How Can I do that.
If any one have an idea please share with me.
In general, there are many different ways to calculate gross profit margin. Be sure you are using the method which is accepted by your companies accounting policies.
Here is an example which looks at all invoices which have been posted year to date and calculates the gross profit margin percentage.
Assuming gross profit margin = total profit / total revenue.
SELECT ( SUM(SUBTOTAL) - SUM(EXTDCOST) ) / SUM(SUBTOTAL)
FROM SOP30200 t1
WHERE t1.SOPTYPE = 3
AND t1.DOCDATE BETWEEN '1/1/2013' AND GETDATE()
This will return a decimal number like .44323. In that case you would be making an average gross profit margin of 44% for every invoice year to date.
SOP30200 = posted sales transaction documents

Resources