Rounding up to the nearest $5 - rounding

I am looking to round up prices to the nearest $5 after a price increase of 3%
I have tried the formula below
= Table.AddColumn(#"Removed Columns", "NewPrice", each Number.Round([Price]*1.03,0,RoundingMode.Up))
So a new price 0f $121 or $124, should come up as $125. Basically, I would like to re-create the Excel formula ceiling(Price*1.03,5)

To round up to the nearest multiple of 5, you need to divide the value by 5, then round up to the nearest whole number, then multiply by 5 again.
Using Number.RoundUp instead of Number.Round is more efficient.
Applying these steps to your code, gives:
= Table.AddColumn(#"Removed Columns", "NewPrice", each Number.RoundUp([Price]*1.03/5)*5, type number)

Related

Simple(r) Excel formula to calculate forward stock (inventory) cover

This is a perennial question for retailers, for which there are a number of solutions in existence:
How can you calculate the "forward cover" of a product knowing its current inventory and armed with forward sales estimates.
eg.
current inventory 100 units (cell A1)
weekly forward sales estimates: 25, 30, 10, 40, 90... (in range
A2:AX)
Here the answer would be 3.875 weeks (3 full weeks plus 0.875 of week 4)
I have a UDF to do this already.
I also have some slightly complicated array functions to do this, eg.
=MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+(A1-SUM(A2:INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1)))/INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+1)
I was wondering if there is a neater way with these 'new-fangled' array functions which have been available for the last few years in later versions of Excel?
Here is another possible solution, although it requires the LET() function which is only available to newer version of excel (2021, 365 and later I believe).
The solution would be the following formula:
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,MMULT(SEQUENCE(1,ROWS(sales),1,0),(ROW(sales)<=TRANSPOSE(ROW(sales)))*sales),
week_full,MATCH(TRUE,inventory<cum_sum,0) - 1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full + 1),
week_full + week_frac
)
Explanation
Given inventory and the forward looking sales estimates, the formula calculates the running total (i.e. cumulated sum) of the sales estimates as shown in the table here below
Inv and Sales
Cumulated Sum
Inv > Cum_Sum
Week
100
25
25
0
1
30
55
0
2
10
65
0
3
40
105
1
4
90
195
1
5
...
...
1
6
The formula goes on to get the number of full weeks of 'forward cover' by finding the the value for the cumulated sum that exceeds the inventory minus one (here 4 - 1 = 3).
Lastly, for the value of the week fraction covered in the last week, the formula calculates inventory minus sum of sales estimates of all previous weeks divided by sales estimate of final week of cover (i.e. (100 - 65) / 40 = 0.875).
Edit
After simplifying the formula you used with the LET() function, I noticed it's doing exactly the same calculation with the only difference of how the cumulated sum is being calculated. Here's your formula using LET():
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,SUBTOTAL(9,OFFSET(sales,,,SEQUENCE(ROWS(sales)))),
week_full,MATCH(TRUE,cum_sum>inventory,0)-1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full+1),
week_full + week_frac
)
=LET(inv,A1,
sales,A2:A6,
cs,SCAN(0,sales,LAMBDA(x,y,x+y)),
m,XMATCH(A1,cs,1)-1,
m+(inv-
IF(m=0,
0,
INDEX(cs,m)))
/INDEX(sales,m+1))
SCAN() is perfect for creating a cumulative sum.
It can be referenced inside XMATCH because of the use of LET.
Here m returns the number of full weeks and the final calculation is the number of full weeks + (inv- cumulative sum up to the full week)/sales of the following week.

Find a growth rate that creates values adding to a determined total

I am trying to create a forecast tool that shows a smooth growth rate over a determined number of steps while adding up to a determined value. We have variables tied to certain sales values and want to illustrate different growth patterns. I am looking for a formula that would help us to determine the values of each individual step.
as an example: say we wanted to illustrate 100 units sold, starting with sales of 19 units, over 4 months with an even growth rate we would need to have individual month sales of 19, 23, 27 and 31. We can find these values with a lot of trial and error, but I am hoping that there is a formula that I could use to automatically calculate the values.
We will have a starting value (current or last month sales), a total amount of sales that we want to illustrate, and a period of time that we want to evaluate -- so all I am missing is a way to determine the change needed between individual values.
This basically is a problem in sequences and series. If the starting sales number is a, the difference in sales numbers between consecutive months is d, and the number of months is n, then the total sales is
S = n/2 * [2*a + (n-1) * d]
In your example, a=19, n=4, and S=100, with d unknown. That equation is easy to solve for d, and we get
d = 2 * (S - a * n) / (n * (n - 1))
There are other ways to write that, of course. If you substitute your example values into that expression, you get d=4, so the sales values increase by 4 each month.
For excel you can use this formula:
=IF(D1<>"",(D1-1)*($B$1-$B$2*$B$3)/SUMPRODUCT(ROW($A$1:INDEX(A:A,$B$3-1)))+$B$2,"")
I would recommend using Excel.
This is simply a Y=mX+b equation.
Assuming you want a steady growth rate over a time with x periods you can use this formula to determine the slope of your line (growth rate - designated as 'm'). As long as you have your two data points (starting sales value & ending sales value) you can find 'm' using
m = (y2-y1) / (x2-x1)
That will calculate the slope. Y2 represents your final sales goal. Y1 represents your current sales level. X2 is your number of periods in the period of performance (so how many months are you giving to achieve the goal). X1 = 0 since it represents today which is time period 0.
Once you solve for 'm' this will plug into the formula y=mX+b. Your 'b' in this scenario will always be equal to your current sales level (this represents the y intercept).
Then all you have to do to calculate the new 'Y' which represents the sales level at any period by plugging in any X value you choose. So if you are in the first month, then x=1. If you are in the second month X=2. The 'm' & 'b' stay the same.
See the Excel template below which serves as a rudimentary model. The yellow boxes can be filled in by the user and the white boxes should be left as formulas.

origin value and after sum after ROUND() is different

I have a table with "ordered amount", "percentages", and "total sum". Note that "ordered amount" and "total sum" should be the same.
column F= sum of C:F
*rows 4,6,8,10 used =round()
As shown in the table(image), for some numbers, value in F is not the same as A when it should be. (e.g. A6(105) and F7(104), -1 after rounding).
Is there anyway to avoid this?
Thank you very much.
If the sum of the decimal points adds up to > 5, your final rounded number will round up. If they add up to < 5, the final number will round down.
Consider this example:
10.5 + 5 = 15.5, which rounds to 16.
However
10 + 5 = 15
This is what is happening in your table.
In order to get the sum of rounded numbers to add up to the same as the sum of the numbers, in your example, you will need to NOT round, but rather subtract, one of the values. I would suggest altering the largest value, as it would seem to have the least effect on the percentages, but that is a choice you can make.
To do that, with your data in row 8, for example you could do the following.
A9: =IF(B$8=MAX($B$8:$E$8),SUM($B$8:$E$8)-SUM(ROUND($B$8:$E$8,0))+ROUND(B$8,0),ROUND(B$8,0))
entered as an array formula with ctrl+shift+enter and fill right to E9.
This would give a sum of 344 which is the same as F8

excel calculate stdev given distribution

I have a table which describes "Products Per User" distribution.
It has 2 columns nProducts and nUsers:
First row has values nProducts = 1, nUsers = 60000, meaning 60000 users bought 1 product.
Second row has values nProducts = 2, nUsers = 20000, meaning 20000 users bought 2 products, and so on...
I want to calculate its STDEV. How do I do it in excel?
In addition, could you tell me how to calculate in excel how many users bought:
nProducts > thresh?
Thanks
Li
Do you mean you want to calculate the standard deviation of the number of products bought? Try this "array formula"
=STDEV(IF(B2:B10>=TRANSPOSE(ROW(INDIRECT("1:"&MAX(B2:B10)))),A2:A10))
confirmed with CTRL+SHIFT+ENTER
So in a small example if you have 1 product bought by 4 people and 2 products bought by 3 people that will give you the standard deviation of the following values
1,1,1,1,2,2,2
Is that what you need?
Note that you can also use this "non array" version
=(SUMPRODUCT((A2:A10-SUMPRODUCT(A2:A10,B2:B10)/SUM(B2:B10))^2,B2:B10)/(SUM(B2:B10)-1))^(1/2)
which calculates standard deviation by calculating the square root of the average of the squared differences of the values from their average value
Just select all the second column values.
Then on the Ribbon bar:
go to Forumulas
click More Functions
select Statistical
click on STDEV.P
At this point as parameters you should have your second column already selected, just clik OK and you will have your Standard Deviation calculated.
In case you can write it manually the formula is =STDEV.P(B2:B10)
I supposed you have values from the 2nd to the 10th row in column B.
Thanks,
Mucio

Compare percentage value against decimal Excel

I am a bit stumped with this issue, I was wondering if anyone could suggest a solution. In Excel I have a table which looks like this:
1 2 3 4 5 Result Score
80% 85% 90% 95% 100% 92.5% 3.50
What I am trying to calculate is that proportional score, based on where the result falls within the preset decimal 1-5 score.
Thanks.
In your case where each increment is 5% you could use a simple calculation like
=MAX(0,F2-75%)*20
[where result is in F2]
....but assuming that you want to interpolate the score given potentially less linear values in your table try this formula where your table is in A1:E2
=LOOKUP(F2,A2:E2,A1:E1+(F2-A2:D2)*(B1:E1-A1:D1)/(B2:E2-A2:D2))
for linear interpolation this would be general formula, just name the ranges or replace with cell references:
= (perc - minperc) / (maxperc - minperc) * (maxscore - minscore) + minscore

Resources