2.375;26.375;0.743|98.375;26.375;0.743|98.375;2.375;0.743|2.375;***2.375***;0.743|2.375;26.375;0.743555
I'm trying to return the second value equaling 2.375 after the 3rd "|". What's the best way to do this?
Thanks!
Asuming the string is in cell A1 (and the numbers are always 5 chars in length), the following formula will work:
=MID(A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1,5)
OR - to handle any length number you can do this:
=MID(A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1,FIND(";",A1,FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)+1)-FIND(";",A1,FIND("|",A1,FIND("|",A1,FIND("|",A1)+1)+1)+1)-1)
This formula will bring the second number after the third | regardless of size.
=--TRIM(MID(SUBSTITUTE(TRIM(MID(SUBSTITUTE(A1,"|",REPT(" ",999)),3*999,999)),";",REPT(" ",999)),999,999))
We can easily make this formula dynamic:
=--TRIM(MID(SUBSTITUTE(TRIM(MID(SUBSTITUTE(A4,"|",REPT(" ",999)),(C1-1)*999+1,999)),";",REPT(" ",999)),(C2-1)*999+1,999))
This will allow you to specify the group and the sequence in that group to return the desired number.
Related
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
My look up array is of format DI-0001. First 3 places are fixed as “DI-“ and next 4 are any number but of fixed length of 4. My look up array is a simple number which is less than 10000. Hence always equals to less than 4 digits. I formatted my lookup value column as “DI-“0000 so as to match the lookup array. But now my match function is breaking down, giving #N/A error. I understand the error, but don’t know how to overcome it.
You are not looking for a number in your look up array so you have to convert the value you are looking up to a string as well, not just format it as string.
=VLOOKUP("DI-"&TEXT(value,"0000"),array,2,0)
Or preferably,
=INDEX(B1:B9,MATCH("DI-"&TEXT(F1,"0000"),A1:A9,0))
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)
I have the data table below, and I want that given a value 'x' look in 'A' and get the lower value in 'B'.
For instance 10.000 should return 0, 38.000 should return 7,8 and 900.000 should return 20. In my locale '.' means thousand separator and ',' is for decimals.
If possible I would like a formula which works in excel and gdocs. Thanks.
A B
0 0
37.500,01 7,8
45.000,01 9,1
58.345,62 11,4
120.206,02 13,6
208.075,91 15,7
295.242,83 17,2
382.409,77 18,2
600.000,01 20
I don't know about gdocs but in excel try the following.
=vlookup(value ; $A$1:$B$9 ; 2 ; 1)
where value is the value you are searching for.
The only prerequisite is that column A must be sorted in ascending order, as you have in your example.
You can use LOOKUP function, assuming lookup value in C2 use this formula in D2
=LOOKUP(C2,A$1:B$9)
The following would work for your needs:
=INDEX(B:B,MATCH(38,A:A,1),1)
Where 38 is the value we are looking up. Match will look in A:A and return the row where the value is less than 38 (because the third parameter of the match() formula is 1).
The Index will return the row in B:B that Match() just outputted.
If you search for 900,000 you're hoping to return the value from 600,000.01, because that's the last value it is higher than.
You can do this with an array formula, but I prefer to make Index do that work for me. As such, I present INDEX/MATCH/INDEX:
First, sort your data in A Largest to Smallest.
=INDEX($B$1:$B$9,MATCH(TRUE,INDEX(900000>$A$1:$A$9,0),0))
You can change 900,000 to whichever number you're looking for, or reference a cell with the value in it.
The second INDEX, the one nested in there, is examining each cell in Col A to determine if your target value is greater than them. It creates an array of TRUE's and FALSE's.
Next, you use MATCH to find the first TRUE in that array you created. That's the position of the first cell that your target is greater than (this is why we sort largest to smallest).
Once we know how far down the list it is, we use the first INDEX to look that far down Col B and grab the info you're looking for!
Play around with it, it makes sense once you think your way through it :) Good luck!
I'm using Excel 2010 and I'm looking for a way to return the first negative number of a column. For instance, I have the following numbers distributed in a column:
1
4
6
-3
4
-1
-10
8
Which function could I use to return -3?
Thanks!
This could be interpreted two ways... If all the numbers are in a single cell (one column) as a string, the MID function can be used. If the numbers are in A1, a formula that could work is this:
=VALUE(MID(A1,SEARCH("-",A1),SEARCH(" ",A1,SEARCH("-",A1))-SEARCH("-",A1)))
If the numbers are each in their own columns (in my example, A3:H3), a different technique must be used:
{=INDEX(A3:H3,1,MATCH(TRUE,A3:H3<0,0))}
Don't type the { } - enter the equation using CTRL+SHIFT+ENTER.
In each case, the formula will return the number -3, which is the first negative number in the series.
Another possibility, avoiding the array formula (which are a big source of performance issues):
=LOOKUP(1;1/(M2:M15<0);M2:M15)
(I assume your numbers are in the M2:M15 range).
This will return the first number matching the "<0" condition. You may use any other condition, including text comparisons.
You may also extract the value of another array corresponding to the matching cell:
=LOOKUP(1;1/(M2:M15<>"OK");T2:T15)
In this example, the first cell containing another string than "OK" will be searched for in the m2:m15 array and the corresponding value in array t2:t15 will be returned.
Please note that the usage of the lookup function should be avoided whenever possible (but in this case, it's very handy !)
(I got the original inspiration for this answer from this post)