can someone please translate this excel spreadsheet cell formula in english words ?
=ROUND(IF(F28 < 1568,2.5,IF(F28 < 2491,0.004873 * F28-5.142,0.02269*F28^0.7329)),2)
am creating a program based from that formula, but i don't understand which one will go first. atleast i understand this part IF(F28 is less than 1568) ...then what?
Start from the outer if statement and move inwards. The comma in the IF function separates the statements like :
boolean expression, true part, and false part
The following is the psuedo code of the above. All the Round are to two decimal places.
IF (F28 < 1568) THEN
ROUND (2.5)
ELSE IF (F28 < 2491) THEN
ROUND (0.004873 * F28 - 5.142)
ELSE
ROUND (0.02269 * F28^0.7329)
If the value in cell F28 is less than 1568, then the value in this cell will be 2.5 rounded to 2 decimal places - i.e. 2.5
If the value in cell F28 is 1568 or more, but less than 2491, then the value in this cell will be:
0.004873 multiplied by [the value in cell F28 minus 5.142], rounded to 2 decimal places
Otherwise (i.e. the value in cell F28 is 2491 or more) the value in this cell will be: 0.02269 multiplied by [the value in cell F28 to the power of 0.7329], rounded to 2 decimal places
You will round the following in this order:
Smaller than 1568 = 2.5
Bigger than/Equal 1568 but smaller than 2491 = 0.004873 * F28-5.142
Bigger than/Equal 2491 = 0.02269*F28^0.7329
Basically that means this:
IF F28 is smaller than 1568 then use 2.5
IF F28 is larger or equal to 1568 but smaller than 2491 then use 0.0004873 * F28 - 5.142
IF F28 is larger or equal to 2491 then use 0.02269 * F28^0.7329
Round the outcome to 2 digits.
Related
Here is my excel table:
The cell with 8.83 = =((C8-B8)*24)-D8
*C8 = 4:50PM
*B8 = 7:30AM
*D8 = 0.50
The cell $371.00 = =(E8*B3)
Why does my total show $371.00 when B3 = $42? It should be $370.86. I don't have it set to round but for some reason it keeps on doing it.
Because, the actual result of formula =((C8-B8)*24)-D8 is 8.833333333. Due to cell formatting you are seeing 8.83. If you want result for only two digit after decimal point then use round function like-
=ROUND(((C8-B8)*24)-D8,2)
Then you will get result 370.86. Or you can directly use in resulting cell.
=ROUND(E8,2)*B3
$371 is “technically” the correct amount, mathematically. You are actually doing rounding when you are hand-calculating your cross-check, and that isn’t matching Excel’s unfounded calculation.
( 4:50pm - 7:30am ) is 9.3333333 repeating, or “9-1/3”. Divided by 24 leaves you 8.8333333 repeating, not 8.83. Excel is doing what it’s supposed to do, and 371.00 is the correct amount. If your use case calls for times to be rounded to .01 hours and no further then you’ll need to apply rounding somewhere in cell E8.
I am trying to make a number round up or round down depending on if it's higher or lower than 0.8
If the number in U6 is for example 16.8, I want cell V6 to round UP to 17.
If the number in U15 is 14.33 I want V15 to round DOWN to 14.
If the number to be rounded will always be positive, then try:
=ROUND(U6-0.3,0)
Use simple round formula like below.
=ROUND(U6,0)
Round() formula with 0 decimal place will automatically round up greater than .5 to its upper integer and round down less than .5 to lower integer.
Try below formula.
=INT(U6)+((U6-INT(U6))>=0.8)
Depending on the condition put in (U6-INT(U6))>=0.8 the formula will return TRUE or FALSE which will be coerced into 1 or 0 due to arithmetic operation.
Consider, for example, the following function strings inside some cells:
A1 = B1 - INT(B1)
A2 = LEN(A1)
A2 will return 17 regardless of the value returned by the function (and thus held) in A1. I suspect that this has to do with the precision returned by INT(B1), but I don't know enough of Excel's inner-mechanisms to confirm.
The end goal is to obtain the length of the decimal part of a number held in B1. For example, if B1 = 978.01194, A2 would hold 5 (LEN(01194)). Obviously this would require a subtraction of 2 to eliminate the counting of the leading (0.) in my implementation above, but that's assuming I can get proper results with this method. Any help or guidance in other methods would be greatly appreciated!
EDIT:I realized that the loss of proper precision occurs only when I subtract the two quantities. INT(B1) returns proper precision, and using its length I can obtain the decimal by subtracting from the original. Would still like to know what is causing the operation in A1 to lose precision internally for LEN.
Alternatives are to use number that is not result from a calculation :
= LEN(B1) - LEN( INT(B1) ) - 1
or round the number to less than 15.95 significant digits :
= LEN( ROUND( B1 - INT(B1), 16 - LEN(INT(B1)) ) ) - 2
= LEN(TEXT(B1,"0.##############")) - LEN(INT(B1)) - 1
Another alternative is to FIND where the decimal occurs and use that as an offset, e.g.
= LEN(B1)-FIND(".",B1)
In general, it is not wise to perform a mathematical operation on a number when what you are really interested in is the text that represents the number for this exact reason. Floating points are not very reliable for dealing with exactness which is why you are experiencing the extra trailing numbers after the decimal in this case.
I just stumbled on an Excel 2013 problem I've never encountered.
Briefly, I have a column (= V for my particular sheet) that returns a 0 or 1 based on two numbers matching exactly (i.e., no rounding errors). This is simple error checking for my work.
In cell F31, I have = 0.1 (manually entered). In cells M31, L31, and J31, I have 4.5, 0.0, and 4.4, respectively. A formula in cell Q31 is
Q31 = M31 - L31 - J31. This is 4.5 - 0.0 - 4.4 = 0.1. None of these numbers come from other formulae. There should be no rounding errors.
Now, in column V31, I have If(Q31=F31,0,1). No doubt that 0.1 [F31] = 0.1 [Q31], but the return value in V is 1. This makes no sense!
If I enter other values so that Q31 does not = 0.1 but F31 = Q31, the return value is 0 (or Q31 = F31) as it should be. For example, I can change F31 to 0.2 and L31 to 4.3 so that 0.2 = 0.2 based on 4.5 - 0.0 - 4.3. This works fine.
What's up with the 0.1?
Many thanks!
Eric
Floating point numbers are "almost never" equal. It's due to floating point arithmetic and precision.
Not all decimal numbers have an exact floating-point representation. A value you enter by hand, must be replaced by Excel by the closest floating-point representation. Also, a value resulting from calculation is replaced by the floating-point unit of the processor by its closest value.
When comparing floating point numbers, use some "epsilon" tolerance. Use something like this for your V31 formula:
=IF(ABS(Q31-F31) < 1e-10, 0, 1)
This compares the two numbers up to the 10th decimal digit.
For flexibility, you can define a "Name" for your tolerance constant, "TOL" in the name manager, so that you can change it in one place without editing your formulas.
=IF(ABS(Q31-F31) < TOL, 0, 1)
The choice of the tolerance depends on your application.1e-10 is a good choice in many cases.
Probably the title is not very suggestive.
Let me explain you with an example. I have:
12345.6
2345.1
12345.00000001
I want those numbers to be roundup to 12350.
How can I do this?
If possible, I would rather use formulas instead of VBA.
You could also use CEILING which rounds up to an integer or desired multiple of significance
ie
=CEILING(A1,10)
rounds up to a multiple of 10
12340.0001 will become 12350
Use ROUND but with num_digits = -1
=ROUND(A1,-1)
Also applies to ROUNDUP and ROUNDDOWN
From Excel help:
If num_digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
If num_digits is 0, then number is rounded to the nearest integer.
If num_digits is less than 0, then number is rounded to the left of the decimal point.
EDIT:
To get the numbers to always round up use =ROUNDUP(A1,-1)
You can use the function MROUND(<reference cell>, <round to multiple of digit needed>).
Example:
For a value A1 = 21 round to multiple of 10 it would be written as
=MROUND(A1,10)
for which Result = 20
For a value Z4 = 55.1 round to multiple of 10 it would be written as
=MROUND(Z4,10)
for which Result = 60
the second argument in ROUNDUP, eg =ROUNDUP(12345.6789,3) refers to the negative of the base-10 column with that power of 10, that you want rounded up. eg 1000 = 10^3, so to round up to the next highest 1000, use ,-3)
=ROUNDUP(12345.6789,-4) = 20,000
=ROUNDUP(12345.6789,-3) = 13,000
=ROUNDUP(12345.6789,-2) = 12,400
=ROUNDUP(12345.6789,-1) = 12,350
=ROUNDUP(12345.6789,0) = 12,346
=ROUNDUP(12345.6789,1) = 12,345.7
=ROUNDUP(12345.6789,2) = 12,345.68
=ROUNDUP(12345.6789,3) = 12,345.679
So, to answer your question:
if your value is in A1, use
=ROUNDUP(A1,-1)