Excel IF .10 Then True Else False - excel

I have the following Excel formula but it is always returning False:
A1 Cell has the value 10%:
=IF(A1="10%","TRUE","FALSE")
I also tried the following:
=IF(A1=".10","TRUE","FALSE")

Or:
=A1=.1
Assuming your A1 cell is Number format and . for decimal.

Try =IF(A1=0.1,"TRUE","FALSE")

The answer depends on if you want to treat A1 as a string or as a percentage.
A1 is a string:
To ensure "35%" is a string, you can type the following in A1:
'35%
The single quote converts it to a string. Your formula should now work.
A1 is a percentage
You need to modify your formula like this, since 10% is really 10/100=0.1:
=IF(A1=10/100,"TRUE","FALSE")

If the value of your percentage is a floating-point number, you should consider that the rounding errors may affect your equality evaluation.
It may be safer to check if the two numbers (the value in the cell A1 and the percentage 10%) are almost equal (e.g. up to 5 digits):
=IF(ROUND(ABS(A1-0.1),5),"TRUE","FALSE")

Related

If cell has zero entered, display zero. If cell has no value, display nothing [duplicate]

Suppose there is an empty excel sheet. Enter formula "=A1" into the B1 cell. The value of B1 would be 0.
My question is: why the value of B1 becomes zero when referring to an empty cell A1? Any rationales Excel behaves this way?
Thanks.
That is because the formula in B1 returns the value of cell A1.
Excel assigns the value 0 to a blank cell.
To distinguish 0 from blank, in B1 enter:
=IF(A1="","",A1)
FWIW, force a zero-length string with =A1&"". This can also be used to show (an apparently blank) cell when a VLOOKUP of INDEX/MATCH wants to return a zero after encountering a blank cell to return. Two caveats: first, a zero-length string is not truly blank and second, if used with VLOOKUP(...)&"" then any true number that should have been returned as a true number becomes text-that-looks-like-a-number. – Jeeped
Quoting the best answer so I can vote on it :)
I changed my application to =formula&"" according to Jeeped, and works great. Kinda dumb that Index returns Value(formula).

Why is =SUMIF(C5:C19,NOT(ISFORMULA(C5:C19))) returning zero?

I have a spreadsheet that I track my hours. Each cell initially is populated with a formula, i.e. =IF(WORKDAY(B24-1,1,holidays2019)=B24,OFFSET(C24,-1,2),0)
and then as the month progresses I enter my actual time.
In the following excerpt all values through 5/10/2019 are entered.
The formula =SUMIF(C5:C19,NOT(ISFORMULA(C5:C19))) shows zero. I do not understand why this does not work.
I appreciate any help! Column B in my spreadsheet corresponds to the dates shown below and Column C to the time entries.
Expected Result: 48.9
=SUMPRODUCT(J6:J20,--NOT(ISFORMULA(J6:J20)))
The key to this solution is the -- in front of the NOT(). A boolean that is processed by a math operator gets converted to 1 or 0. --, +0, -0, *1, /1 would have all worked to do the conversion. So now you wind up with an array of values you may want to sum being multiplied by an array of 1 and 0 to indicate the ones you want. The 1 are manual entry and the 0 are your formulas entries.
Now SUMPRODUCT performs array like calculations. As a result avoid using full column/row references inside it or you will wind up with a lot of excess calculations. Adjust the ranges in the answer to suit your needs.
Here's the MSDN definition of the Criteria in =SUMIF
criteria Required. The criteria in the form of a number, expression,
a cell reference, text, or a function that defines which cells will be
added. For example, criteria can be expressed as 32, ">32", B5, "32",
"apples", or TODAY().
Important: Any text criteria or any criteria that includes logical or
mathematical symbols must be enclosed in double quotation marks (").
If the criteria is numeric, double quotation marks are not required.
So, the reason, why your SUMIF returns 0 is, because none of the cells match the criteria, as they return a number and meanwhile they expect FALSE
Another issue here being, that the ISFORMULA will return TRUE, even when a range contains a single formula while all the rest has none. So basically you need to drag the formula down for each cell individually and sum them up only when a value is TRUE
Starting from cell D1:
=ISFORMULA(B1)
And then you can simply sum them up with the formula you provided.
=SUMIF(D1:D16,TRUE,C1:C16)
Obviously, you can hide the column D to make it more aesthetically pleasing.
Your formula fails because the criteria you're matching against, is TRUE/FALSE. Obviously the values in C5:C19 don't contain any booleans, so the sum is 0.
To solve this, you can add the correct criteria in cell D5 and below: =ISFORMULA(C5)
Then use =SUMIF(D5:D19,FALSE,C5:C19) to sum the values in column C.

Sum of numbers + 0

I am having a problem with a small number. I am using SUM function to sum certain numbers. If I add a zero to the range, it is not displaying zero. I don't know why.
A1
=SUM(B1:R1)*-1
C1 to L1
266864 -100000 -15136.15 -23688.82 -120870 -7169 -5550 1224 -0.03 4326
A2
=SUM(B2:R2)*-1
C2 to M2
=SUM(C3:C3) =SUM(D3:D3) =SUM(E3:E3) =SUM(F3:F3) =SUM(G3:G3) =SUM(H3:H3) =SUM(I3:I3) =SUM(J3:J3) =SUM(K3:K3) =SUM(L3:L3) =SUM(M3:M3)
A3
=SUM(B3:R3)*-1
C3 to M3
266864 -100000 -15136.15 -23688.82 -120870 -7169 -5550 1224 -0.03 4326 0
A1 is displaying 0, but A2 and A3 displays 9.09E-13
The number 9.09E-13 is another way (scientific notation) of saying 0.000000000000909495, a very small decimal number. What you are experiencing is a 15 digit precision floating point error.
    
Typically, you would use the ROUND function or something similar to remove the error (if you have to).
See Floating-point arithmetic may give inaccurate results in Excel for more information.
as I think,
might be some different formula on A1 cell is already placed or the type of A1 Cell is int and Value becomes in decimal or else, so make try this formula in different cell.
I wonder why you are using =SUM(C3:C3) etc. That is, Why use the sum function on a single cell. Unless there is a specific reason, I suggest you use = C3 instead. I've found that using the summation on a single cell can sometimes return answers that are incorrect. Don't know why, but it does. Therefore, long ago I quit using the sum unless there is a range that includes more than one cell.

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)))

Conditional Formatting based on number in a cell that contains both text and numbers

If cell A1 has the value "600 T" is there a way to apply the number less than/between/greater than conditonal formatting based on the number, essentially ignoring any text that may be in the cell?
Boolean operators such as AND already return TRUE or FALSE.
So this:
=IF(AND(VALUE(LEFT(A1,3))>=X,VALUE(LEFT(A1,3))<=Y),TRUE,FALSE)
… is equivalent to:
=AND(VALUE(LEFT(A1,3))>=X,VALUE(LEFT(A1,3))<=Y)
You can cast strings to numbers by multiplying by 1.
So this:
=VALUE(LEFT(A1,3))
… is equivalent to:
=LEFT(A1,3)*1
Using these techniques reduces your formula:
=IF(AND(VALUE(LEFT(A1,3))>=X,VALUE(LEFT(A1,3))<=Y),TRUE,FALSE)
… to this:
=AND(LEFT(A1,3)*1>=X,LEFT(A1,3)*1<=Y)
Since your numbers may also have 4 digits, you can return the numeric portion like this:
=LEFT(A1,FIND(" ",A1))
This does returns the space: "600 " … but that's not a problem since you're casting it to a number.
So your final formula would look like this:
=AND(LEFT(A1,FIND(" ",A1))*1>=X,LEFT(A1,FIND(" ",A1))*1<=Y)
Update
If your numbers don't include text, the above formula will fail with #VALUE!, because FIND is looking for a space that doesn't exist.
You can fix this by appending a space to FIND's second argument. So your true final formula will look like this:
=AND(LEFT(A1,FIND(" ",A1&" "))*1>=X,LEFT(A1,FIND(" ",A1&" "))*1<=Y)
=VALUE(LEFT(A1,3))<=X
=VALUE(LEFT(A1,3))>=X
Checks if first 3 characters (if a number) of A1 is less or greater than X.
=IF(AND(VALUE(LEFT(A1,3))>=X,VALUE(LEFT(A1,3))<=Y),TRUE,FALSE)
Checks if first 3 characters (if a number) of A1 is between X and Y.
MID or RIGHT can be used instead to check digits in the middle or end of a string.

Resources