Error in formula when comparing two separate formulas - excel

I have the first and second formula to make sure the number I get is the same, which it is (32). The bottom formula however displays false and I have no clue why. (JA2 has a formula which outputs "32(22)"). Can anyone help me understand how they are not equal?
=LEFT(JA2,2)
=ISOWEEKNUM(TODAY())
=LEFT(JA2,2)=ISOWEEKNUM(TODAY())

LEFT returns a string ISOWEEKNUM returns a number. A string will not equal a number. Turn the string to a number:
=--LEFT(JA2,2)=ISOWEEKNUM(TODAY())
The -- or double unary is akin to -1*-1* which will change the string to a number if possible or return an error. So you may want to use IFERROR to deal with that possibility:
=IFERROR(--LEFT(JA2,2),60)=ISOWEEKNUM(TODAY())
Now if the Left is a string that cannot be converted to a number the formula will return 60 and since there can only be a max of 53 weeks it will return FALSE

Related

Excel: Dividing a Number with Greater Than Symbol and Less Than Symbol (i.e. >15/5, <20/5, >20/5)

Imagine A1 is a cell that I put numbers in and A2 is a cell that will automatically give the vaule of A1 divided by 5.
=A1/5
But when I enter a number to A1 with a greater than symbol (>) or a less than symbol (<) such as >15, A2 gives #VALUE! instead of >3. Is there a way to code this please?
I can't comment yet but I'd like to add an explanation to Jos Woolley's answer
=IF(N(A1),A1/5,LEFT(A1)&MID(A1,2,99)/5)
N(A1) Is using the property of the N function to check if the value in A1 is a number or, in your case, a number with an operator in front of it. If the value of A1 is a whole number, A1/5 is produced, and if A1 has an operator (</>) then LEFT(A1)&MID(A1,2,99)/5 will be produced.
The LEFT(text, [num_chars]) function takes a cell value and recreates that cell, from the left, for a total number of characters put into the function in the [num_chars] parameter. If no parameter is set, the single leftmost character will be used, in you case, it will be < or >.
& is used to string together calculated cells, and in this case is being used to take the < or > from the LEFT function and adding the MID function to it.
The MID function is like the LEFT function, only you can choose the starting character, rather than start at the beginning of the string. What's happening in MID(A1,2,99) is taking the value in A1, for example >15, and starting at the second character, recreates the next 99 characters. This means as long as the number you're using to divide is 99 digits long or less, this formula will work fine. This value is then divided by 5.
I hope that's a good enough explanation, since you said you didn't understand what it meant at first. Glad that it works for you!
Also, because of your comment, I'm assuming it looks something more like
=IF(N(A1),A1/5,LEFT(A1)&ROUND(MID(A1,2,99)/5,1))
Which would indeed get you your result :)
=IF(N(A1),A1/5,LEFT(A1)&MID(A1,2,99)/5)

Excel - How to SUM the results of LEFT?

In row 2, I used =LEFT(B1,(FIND("/",B1,1)-1)) to get the 288 and ‭‭‭‭233‬‬‬‬. But when I tried to =SUM(B2:C2), it returned a 0. How do I SUM the results of LEFT()?
When you use LEFT() function then it returns result as string (not as number). So, you can not sum string. You need to convert string to number. You can use below formula
=LEFT(B1,(FIND("/",B1,1)-1))*1
Or use
=--LEFT(B1,(FIND("/",B1,1)-1))
Then sum output.
You can directly sum lefts before / by following formula.
=SUM(--LEFT(B1:C1,SEARCH("/",B1:C1)-1))
force the 288/233 to a number. the easiest way is =LEFT(B1,(FIND("/",B1,1)-1))+0

How to construct an intersect formula in Excel?

I currently have a column of data with numbers. I want to create a second column which returns TRUE when a set of multiple conditions are TRUE. This column should return FALSE when one or more conditions are FALSE. The conditions are the following:
The number is negative (<= 0)
The number in this list is the closest to zero
The number in this list is not #N/A
The big trouble I'm having is because of these #N/A's in my dataset. I can't get my formula to ignore it. This is the current formula I use in column B, but for some reason I can't get this to work:
=IF(AND(A1<=0;A1=MAX(IF(NOT(IFNA($A$1:$A$300;TRUE));TRUE;FALSE)));TRUE;FALSE)
I suppose something's wrong in my interpretation of the IF(NOT(IFNA(...)) part.
Sorry if it's obvious, but can anyone help me out here?
I would use aggregate because there is an option to exclude NA's:
=IF(ISNA(A1),FALSE,A1=AGGREGATE(14,6,A$1:A$10/(A$1:A$10<0),1))
(this is assuming the number should be equal to the nearest negative number to zero, in other words the highest negative number. In this case you don't need a separate test for the number being negative)
I would use the array formula:
=IF(ISNA(A1),FALSE,IF(A1>0,FALSE,IF(A1=MAX(IF(A:A<0,A:A)),TRUE,FALSE)))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Right(text;5) is not the same as a 5 character text

I have a match function that I could not get working. I boiled it down to the point that it can't find the appropriate match since the values are not the same, apparently.
I have the value 21337 in cell D59. In cell S59 I have the function: Right($d59;5), which displays 21337. However when I enter in a cell: =D59=S59 i get the return FALSE.
I use the Right() function because cells in column D contain concatenated values, where the last 5 values are of importance. For example D60 contains 21337 - 21448, where 21448 is the value I want to match.
Anyone has a clue on what might be the problem?
With no formatting you'll see that 21337 is right aligned - showing this is a number and treated as a number by Excel.
On the other hand Right($d59;5) will show the number left aligned, indicating that the returned value is being treated as text by Excel.
If you try Right($d59;5)*1 Excel will implicitly convert the value back to a number (due to the calculation performed) and both values will be equal.
To be explicit about the conversion, as Brian has pointed out, use VALUE(Right($d59;5)).
If you use "Formula" > "Evaluate Formula", does it show the penultimate Evaluation as21337="21337"
The LEFT(..) function will convert the number to a string, and the string and the number will not equate. Try either =TEXT(D59,"#")=S59 or =D59=N(Left(S59)) to convert in your comparison, or change the code in S59 to =N(Right($D59,5)) to make S59 show a number
(The N(..) function converts a string to a number, returns 0 if Not A Number)

using array formula to average if

i have some cells d1:d10. Some have numbers, others contain "". The "" is the result of an =iferror(,"") function to leave a blank cell.
I am trying to average d1:d10 but only including the cells that are not "".
I have =AVERAGE(IF(D12:D51<>"",D12:D51)) followed by ctrl+shft+enter but it is still taking the average of all the cells (essentially taking the sum and dividing by 10, where I want it to take the sum and divide by less than 10 depending on the number of "" cells)
I couldn't reproduce your problem in Excel 2013.
Normally, Excel's average function ignores text, empty cells and logical values. So, the following formula should do what you are trying to do.
=AVERAGE(D1:D10)
The if clause in your function returns either some numbers or FALSE. Again, normally, Excel's average function ignores FALSE values so it shouldn't behave like you said. If it somehow is converting boolean values to numeric values based on Excel's version (FALSE to zero) you can just give a string instead of a boolean value so it has to ignore those values:
=AVERAGE(IF(D1:D10<>"", D1:D10, "s"))
Alternatively you can calculate the average without the average function:
=SUM(IF(D1:D10<>"", D1:D10))/COUNT(IF(D1:D10<>"", D1:D10))

Resources