concatenate the cell value with result of If formula - excel

I have the formula below which checks cell C6 and if C6="Yes", formula will return "X".
IF(C6="Yes","X","")
I now want this formula to concatenate the value of Cell C5 to string "X" only when the C6="Yes". How can I formulate this?
Thanks in advance!

Like this, using & to concatenate:
IF(C6="Yes","X"&C5,"")

As an addendum to Scott's answer, depending on your purpose you can also use CONCAT or TEXTJOIN. For instance:
=IF(C6="Yes",CONCAT("X",C5),"")
...or...
=IF(C6="Yes",TEXTJOIN(" ",TRUE,"X",C5),"")
If C5 is "example", these would result in "Xexample" and "X example", respectively. As Plutian mentioned, this is particularly useful if you're going to have more entries. TEXTJOIN is particularly useful if you're trying to make a sentence or concatenate an address separated by commas. It can also ignore blank cells, which can be handy.

Related

How to get a cell and the immediate cell below it in a table

Is there a way that I can get all the cells that contain "Student" along with the cell that's below it and put it in another table next to each other?
Maybe this picture will illustrate my problem better:
The main problem is to simply look in a column all the cells that contain "Student" and get the cell right below it too (discard everything else).
Will the best approach be to use VLOOKUP() or the SEARCH(), I'm struggling to create a formula for this small task. Any help would be greatly appreciated.
Just HSTACK two filters, the second with and offset range:
=HSTACK(
FILTER(A3:A17,ISNUMBER(SEARCH("Student",A3:A17))),
FILTER(A4:A18,ISNUMBER(SEARCH("Student",A3:A17))))
^^^^^^Note the offset
With irregular spacing:
This answer is based on your previous thread, I can update the formula's if needed but I am guessing this example above is just an example?
This will require a helper column to my understanding, in order to trim out the fat.
B1
=IFERROR(FILTER(FILTER(A1:A1000,NOT(ISNUMBER(FIND("titanium",A1:A1000)))*NOT(ISNUMBER(FIND("beagle",A1:A1000)))*NOT(ISNUMBER(FIND("legend",A1:A1000)))*NOT(ISNUMBER(VALUE(LEFT(A1:A1000,FIND(".",A1:A1000)-1))))),FILTER(A1:A1000,NOT(ISNUMBER(FIND("titanium",A1:A1000)))*NOT(ISNUMBER(FIND("beagle",A1:A1000)))*NOT(ISNUMBER(FIND("legend",A1:A1000)))*NOT(ISNUMBER(VALUE(LEFT(A1:A1000,FIND(".",A1:A1000)-1)))))<>0),"")
C1 Required to be dragged down for X number of cells
=IFERROR(INDEX(FILTER(IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000),IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000)<>0),ROWS(C$1:C1)*2-1),"")
D1 Required to be dragged down for X number of cells
=IFERROR(INDEX(FILTER(IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000),IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000)<>0),ROWS(D$1:D1)*2),"")
B1 will filter the data, and cells C1 and D1 will strip out the text you are looking for.
I know am late to the party, but you can try this something along the lines using TAKE(), TRANSPOSE() & WRAPCOLS()
• Formula used in cell C3
=TAKE(TRANSPOSE(WRAPCOLS(A3:A17,5)),,2)
Note: This works if the spacing is consistent.
For Irregular Spacing using XLOOKUP(), FILTER() & HSTACK()
• Formula used in cell H3
=LET(_Student,FILTER(F3:F17,ISNUMBER(SEARCH("Student",F3:F17))),
HSTACK(_Student,XLOOKUP(_Student,F3:F17,F4:F18)))

Search row for matching partial strings then concatenate strings in new column

Apologies if this is something really obvious but egads it's driving me crazy and I can't find a non-array/helper box answer.
I want to search cells D2 and E2 for matching numbers, and then concatenate these (using TEXTJOIN?) for each row in cell F2 (and then copy the formula down the column). So for eg I can see that D2 and E2 share unit 2, and cells D4 and E4 both have units 1 and 2 - so I'd like F4 to show "1,2". I want it to search for any and all numbers that match across both columns and return this in F as a comma-delimited concatenated string. Any help gratefully received.
As per the comments you can use FILTERXML() to retrieve the correct data:
=IFERROR(TEXTJOIN(",",,FILTERXML("<t><s>"&SUBSTITUTE(D2&","&E2,",","</s><s>")&"</s></t>","//s[following::*=.]")),"None")
For tips & tricks on how to use FILTERXML(), please see this post here on SO.

Excel IF statements, with 3 conditions if a=true and b=true and c=true then d1 = ""

I want to make an excel formula so that, I can test out 3 columns and if they are true then to set a new value to the 4rth column.
I have this formula:
=IF(AND(A1="ALFA ROMEO"; B1="159"; C1="55");D1="2016";D1="")
and I want to check if A1 and B1 and C1 are true then to set D1 equal to a certain value.
*I've tried many complex ways to achieve it but this formula is the only one that doesnt pop up an error, but still gives back the Value FALSE(Not in D1, but in the cell I tried it). I've also tried seperating with commas etc...
Any possible help or way I could achieve the check?
It should come from the quote ("") around the number
I've try this
=SI(ET(A1="ALFA ROMEO";B1=159;C1=55);2016;"")
and it worked for me (sorry it's in french).
Maybe try to change cell format from the column B and C.
And also put the formula in cell D1 or in the cell you want the value.
You're almost there, but you need to put this formula here in cell D1 in order to fill the value of D1:
=IF(AND(A1="ALFA ROMEO", B1=159, C1=55),2016,"")
Keep out: in my locale I'm working with commas, while you might be working with semicolons, so your actual formula might be (in cell D1):
=IF(AND(A1="ALFA ROMEO"; B1=159; C1=55);2016;"")
Also, no need to put numerical values (159, 55) as strings, as you can see.
Edit: about turning B1 into a string:
I've just created this formula:
=IF(TEXT(B1,"0")="159","TRUE","FALSE")
This allows you to convert B1 into text.
So, your formula might turn into something like:
=IF(AND(A1="ALFA ROMEO", TEXT(B1, "0")="159", TEXT(C1,"0")="55"),2016,"")
(Again, mind the locale settings (commas and semicolons))

Excel - using cells in equations

Is there any way to use cells of excel in my mathematical equations? I'd like a way to just change the numbers and the equations automaticlly update with them. I tried concatenating strings but it's not that pretty. Or maybe is there any other way to easily show equations step by step in excel?
You say that concatenation of strings is not that pretty, so I assume you have done something like:
in cell A1 : "Hello"
in cell A2 : "World"
in cell A3 : =A1&A2
And in cell A3, you see "HelloWorld", without any space (which is indeed not pretty).
You can solve this in two ways in A3:
=A1&" "&A2
=TEXTJOIN(A1:A2, " ")
(I'm not entirely sure about the syntax of the second one.)
In the first formula, you concatenate both cells A1 and A2 and you specifically mention to put a space between those two.
In the second you do the same, but you mention that the space must be used everywhere.
The difference can be seen in following example:
In cell A1: "Hello"
In cell A2: "Lovely"
In cell A3: "World"
In cell A4, you can put: =A1&" "&A2&" "&A" for getting "Hello Lovely World": you need to mention the space character twice.
In cell A4, you can put: =TEXTJOIN(A1:A3, " ") for getting the same result. As you see you only need to mention the space character once.
Is this what you are looking for?

Nested IFs in function not working

Hi, I'm trying to input a function in C2 in order to assign a numerical value to the minutes given in Column B. The criteria for this can be seen in the image above (starting at G1).
I have tried using a formula I copied from a similar situation but is not working:
=IF(B2<=$A$2,5,IF(B2<=$A$3,4,IF(B2<=$A$4,3,IF(B2<=$A$5,2,1))))
Any help would be appreciated, thanks
The suggestion by #Jeeped above will simplify the formulas needed. If you have to keep the 'A' and 'B' cells as they are listed above, you have to extract the number from the 'x min' format and convert the 'x' to a number so it can be compared (I assume a " " exists after the number. Could search for " min" as well).
=VALUE(LEFT(A2,SEARCH(" ",A2)-1))
Using the above, if A2 = '60 min', the formula will produce a '60'.
Now that the cell contents can be treated as numbers, the comparisons can be made. Formula for C2:
=IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$2,SEARCH(" ",$A$2)-1)),5,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$3,SEARCH(" ",$A$3)-1)),4,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$4,SEARCH(" ",$A$4)-1)),3,
IF(VALUE(LEFT(B2,SEARCH(" ",B2)-1))<=VALUE(LEFT($A$5,SEARCH(" ",$A$5)-1)),2,1))))
This is ugly, but works given the original question.
Try this formula (in this case for C2):
=SUM((B2<=$A$2:$A$5)*1)+1
It is important to use it as array formula. So after typing or inserting this formula to your cell don't just commit with Return but hit Ctrl+Shift+Return. If you did it right, your formula will be surrounded by curly brackets in formula bar:
{=SUM((B2<=$A$2:$A$5)*1)+1}

Resources