Rounding cell value to nearest thousand in excel - excel

I have been trying to round a cell value up or down to the nearest thousand but can't get it to work. I'm trying to calculate my hourly rate based on the current exchange rate from USD to VND But if the resulting total is something like 22,325 then it should round down to 22,000 and likewise if the hundreds are 500 or more it should round up to 23,000
So where the hourly rate says 527,325 it should round down to 527,000. The cell already contains a formula to multiply the the current exchange rate by the USD.

Using the ROUND function:
=ROUND(A1,-3)
Where A1 is the cell containing the number you wish to round.
The negative number specifies digits to the left of the decimal point to replace with zeros (the number of zeros at the end of the number).
Like so:
=ROUND( 34528, -3 ) = 35000
As for the OP's example:
=ROUND( 22325, -3 ) = 22000
The OP also stated:
likewise if the hundreds are 500 or more it should round up to 23,000
=ROUND( 22500, -3 ) = 23000
See ROUND Function Office support

You can also try this:
=MROUND(A1,1000)
This should give you what you want.

You've asked specifically for a formula that when it 'says 527,325 it should round down to 527,000'. For this you would need the FLOOR¹ function or ROUNDDOWN¹ function.
=FLOOR(A1, 1000)
=ROUNDDOWN(A1, -3)
There is also leaving the number alone but formatting with a custom number format of 0, K but this does not round down. If the number was 527,501 it would display 528 K not 527 K.
      
¹ The counterparts to FLOOR and ROUNDDOWN are the CEILING function and ROUNDUP function.

Divide by 1000, then round, then multiply by 1000.
The formula for rounding A1 in this way would be:
=ROUND(A1/1000)*1000
If a formula already exists in the A1 cell, just replace the A1 with the new formula in the upper expression.

Related

Excel - standard deviation where source cells are a count

I have some data that looks like this
Condition 1
Condition 2
Condition 3
Condition 4
Condition 5
0
0
0
70
0
0
50
10
0
0
120
0
0
5
5
Where the value in each cell is the number of meters of an asset that is the given condition. Or in other words, a count of the number of meters that are a '4'.
How do I calculate a standard deviation for this? Obviously the std.dev would be '0' for the first row, higher for row 2, and fairly low for row 3.
Something similar to REPT, but that repeats a value x times in a formula?
I considered a helper column but the number of meters that there are in total makes this impractical.
I am not a math expert, but I can show you how to "make a range of numbers" based on the criteria shown, using Excel 365.
Suppose your data is in the range B2:F4 as shown below. In cell G2, enter the following formula and drag it down:
=STDEV.P(--FILTERXML("<t><s>"&TEXTJOIN("</s><s>",1,REPT($B$1:$F$1&"</s><s>",$B2:$F2))&"</s></t>","//s[number()=.]"))
The above will calculate the standard deviation using the STDEV.P function, but I am unsure if this is the right function to use as there are many other variations to the original STDEV function.
Regardless, the following part of the formula is able to return a range of numbers as desired:
=--FILTERXML("<t><s>"&TEXTJOIN("</s><s>",1,REPT($B$1:$F$1&"</s><s>",$B2:$F2))&"</s></t>","//s[number()=.]")
You can view this question and the answer by JvdV to understand the use of the FILTERXML function.
Another way of doing it is to use the alternative SD formula
which would give you
=SQRT((SUM(A2:E2*COLUMN(A2:E2)^2)-SUM(A2:E2*COLUMN(A2:E2))^2/SUM(A2:E2))/SUM(A2:E2))
for the population standard deviation.
The Excel 365 version using Let is more readable I think:
=LET(x,COLUMN(A2:E2),
mpy,A2:E2,
n,SUM(mpy),
sumxsq,SUM(mpy*x^2),
sumsqx,SUM(mpy*x)^2,
numerator,sumxsq-sumsqx/n,
SQRT(numerator/n)
)
A bit less obviously, you could get it from the original formula
=SQRT(SUM(A2:E2*(COLUMN(A2:E2)-SUM(A2:E2*COLUMN(A2:E2))/SUM(A2:E2))^2/SUM(A2:E2)))
Again, in Excel 365 you could write this as:
=LET(x,COLUMN(A2:E2),
mpy,A2:E2,
n,SUM(mpy),
xbar,SUM(mpy*x/n),
numerator,SUM(mpy*(x-xbar)^2),
SQRT(numerator/n)
)
Change the denominator to
(SUM(A2:E2)-1)
for the sample standard deviation.
I ended up figuring it out.
I added a column which calculated the average. (Say column F)
I then had a formula like this
=SQRT(SUM(A2*POWER((1-F2),2),B2*POWER((2-F2),2),C2*POWER((3-F2),2),D2*POWER((4-F2),2),E2*POWER((5-F2),2))/SUM(A2:E2))
Essentially this calculated the variance from the mean for each condition value, multiplied by the number of values (e.g. number of meters) of asset that are that particular condition, then did the normal other standard deviation calculations (sum, divide by total, square).

Get random value in the range of plus/minus 10% of a cell value in Excel

I have a column with positive numbers and want to calculate for each of them a random value, which is however placed in the range of 10%, so the calculated value is maximally 10% lower or higher as the original value.
The second requirement is - the result must be higher then zero.
I tried a formula like the following - but it seems to be wrong, because of not matching the second requirement, i get sometimes values lower then zero.
=IF(RAND()<0.5,(B2+(B2/100)*90)-(RANDBETWEEN(B2-0.1,B2+0.1)),(B2-(B2/100)*90)+(RANDBETWEEN(B2-0.1,B2+0.1)))
If you are only dealing with integers and your value is in B2, why not just use RANDBETWEEN(B2*0.9, B2*1.1). If B2 is positive, this cannot return a negative number since 0.9 * a positive number will still be positive.
If you want to have floating point numbers, you can use RAND() to generate a random number between 0 and 1, then subtract 0.5 and divide by 5 to get a number between -0.1 and 0.1. Then you can add 1 and multiply that by the original value to get something between 0.9 and 1.1 times it:
=(1+(RAND()-0.5)/5)*B2

how to add zeros after numbers to get a fix length in EXCEL

I have 3 numbers in excel.
A1. 498
A2. 899
A3. 5209
I want the numbers as the followings:
B1. 49800
B2. 89900
B3. 52090
I am still finding the solutions via online but most of the resource is discussing about leading zeros.
Please, could you kindly give me any ideas? Thanks.
I hope this formula may be of some use:
=A1 & REPT("0"; 5 - LEN(A1))
Thought this does not set the format of the cell itself (which I doubt can be done as you are changing the value of the cell by adding the zeros)
The formula only works if you are dealing with numbers as text, so you may need to convert them to text in the formula (TEXT(A1; "0") instead of A1)
you can do this one quite easily without VBA - using an IF and the very handy REPT function:
=IF(LEN(H13)<5,H13&REPT(0,5-LEN(H13)),H13)
Essentially - if the length is less than 5 - you repeat 0 up to the amount of times that its missing.
Seems like simple math to me. Essentially you want to shift left (base 10) a certain number of times. We can do this by:
Calculate the ceiling of the base-10 logarithm of the value to get it's "length"
Subtract the result from the target "length" of 5, this is the number of places we want to shift
Take 10 to this power and multiply back by the value.
In other words, where x represents the value in column A you want to transform:
In Excel, this would be expressed as:
=A1*POWER(10,(5-CEILING(LOG10(A1),1)))

excel forumal round off the values

In excel formula I am in need to round off the values. So my query is how I can set the function if 4th decimal value greater than or equal to 5 means I need to round off the 3rd value. This is what my query.
Set the cell A1 to 1.23456789
Set A2 to "=ROUND(A1,3)"
A2's value shows as "1.235"
The round function takes as the first parameter, the number you wish to round off. The second parameter is the number of decimal places to keep before the rounded slot. So, you want the decision to be made off the 4th decimal, set the second parameter to 3.
EDIT (due to comment) :
So, check the 4th decimal place and if >= 5 round at 3rd place, else don't touch value at all?
If the number is A.BCDEFGHIJ... then if E >= 5, return A.BCD or D+1 if we round up, or if E<5 return full number A.BCDEFGHIJ...
=IF((MOD(A1*10000,10)>=5),ROUND(A1,3),A1)
So, if A1 = 1.23456789, then the answer is 1.235 but if A1 = 1.23446789, then the answer is 1.23446789
How it works :
I take A1 and multiply by 10000 to make the 4th digit to the left of the decimal, then modulus with 10, to remove all other digits and then check that digit against a value of 5. If >=5, we round off at the 3rd decimal place, otherwise, we return the full number.

How to round decimal values for specific rule

I want to use a rule in excel for specific values.
If price>=8.40 then price should be 8.99 and if price<8.40 then price is 7.99. Meaning if decimal value is >=40 then it should be .99 with same starting digit but if decimal value is <.40 then it should be starting value -1 and then .99. Sorry if i am unable to explain my requirement. Some examples are given below.
Present price New Price
8.40 8.99
8.39 7.99
8.41 8.99
8.25 7.99
Try this one:
=ROUND(A1+0.1,0)-0.01
Suppose the Present Price values reside in 'A' column, add the worksheet formula shown above in New Price Columns' first cell (e.g. B1) and expand it to the end of populated range.
Note: regular Excel Round() to Integer worksheet Function typically uses value of 0.5 as a threshold for rounding up (otherwise it will round down to the nearest Integer). So, just increasing the value by 0.1 should suffice your task).
Hope this will help. Rgds,

Resources