Concatenating Text - google-sheets

I need to concatenate text from various cells to a single cell in a row. This can go to an infinite number of rows.
How to use the CONCATENATE function in Google Sheets for doing this?
I also need to know how to use "if else if" in Google Sheets. For example:
IF(A2="This")
JOIN(" ", A2,B2)
ELSE IF(A2="I")
JOIN(" ",A2,C2)
ELSE IF(A2="value")
JOIN(" ",A2,D2)
Is this possible in Google Sheets?

Simply use jon function:
=join(" ", a2:e2)
You may also like this arrayFormula solution:
Google sheet arrayformula join() and split() functions

to merge text:
=CONCATENATE(A1;" ";B1;" ";C1;" ";D1;" ";E1)
And yes you can use CONCATENATE in IF formula.

Try something like this
if(A2="This",JOIN(" ", A2,B2),IF(A2="I",JOIN(" ",A2,C2),IF(A2="value"),JOIN(" ",A2,D2),"Else Value")))
Syntax
IF(logical_expression, value_if_true, value_if_false)
you can refer these links
https://productforums.google.com/forum/#!topic/docs/CmebALbskuo
https://support.google.com/docs/answer/3093364?hl=en

Related

Extract Substrings using importxml in google sheets

Using IMPORTXML in google sheets. I want to extract part of the result into one cell.
=IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")
I got the result spread over several columns. B8:F8
The inspect element is like this. I only want the value "2". It is in cell B8.
I think this can be done using substring-after. But I could not get the correct result.
In your situation, how about the following samples?
=REGEXREPLACE(JOIN("",IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")),"[^0-9]","")
=REGEXEXTRACT(JOIN("",IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")),"\((.*)\)")
References:
REGEXREPLACE
REGEXEXTRACT
I use this formula. That works too.
=INDEX( IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span"),3)
But tanaike's formula is very good.

Textjoin or Concatenate for this case?

hope you have a good day/evening.
Due to I always seems to use importrange function to import multiple sheets. I want to have a quicker way to replace the date (highlighted in red as per the screenshot) with the date referenced in Col A. This is my Google Sheet under the tab name "TextJoin" Google Sheets Link
try:
=INDEX({""; "={"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}"})
but you may need to wrap it into query and remove empty rows perhaps like:
=INDEX({""; "=QUERY({"&TEXTJOIN("; ", 1,
"IMPORTRANGE(""13DWtP4L7swqBgK6BGLeA-o_FfyD-D8-Ru30cOPf0I10"", """&
FILTER(TO_TEXT(A2:A)&"!A2:C"")", A2:A<>""))&"}, ""where Col1 is not null"", )"})
Try
=importrange("_____","'" & text(A2,"M/d/yy") &"'!A2:C")

Google Sheet Filter function and Concatenate in a Cell

To All Google Sheet Expert,
I need help to solve this problem in my google sheets.
Problem
Based on my previous search and question, I can use combination between TextJoin and Filter.
How can I achieve those expected result?
What should I fill in M4, M5, N4, N5, O4, O5?
This is link to my sheets
Thank you in advance.
One possible approach
This is for cell M3 for example:
=JOIN(
CHAR(10),
ARRAYFORMULA(
(FILTER(E3:K3, VLOOKUP(E3:K3,$A$4:$B$10,2,FALSE) = M2))
&" "&
(FILTER(E4:K4, VLOOKUP(E3:K3,$A$4:$B$10,2,FALSE) = M2))
)
)
Starting from the inner-most formulae
The VLOOKUP is needed to match the food name to the type.
This value is then used to FILTER BOTH the price and the titles of the food. You need two filters for this, one for the price and one for the title. Using onlt this it will give you:
These two rows now need to be concatenated with the & symbol, wrapped in an ARRAYFORMULA.
Finally these rows need to be joined with JOIN using a newline CHAR(10).
Reference
VLOOKUP
ARRAYFORMULA
CHAR
JOIN

Can I use an arrayformula with a split arrayformula inside it?

Trying to break apart rows containing numbers like "198,183,158,315,274" by their comma, and then average them out and divide them by a singular number; using arrayformula. It only produces one row of result and it's incorrect though?
Here is my test sheet, editable
Thanks for any help.
try:
=ARRAYFORMULA({"Average"; IF(A4:A="",,
IFNA((MMULT(1*IFERROR(SPLIT(INDIRECT("A4:A"&
MAX(IF(A4:A="",,ROW(A4:A)))), ",")),
ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(A4:A, ","))))^0)/
(1+LEN(REGEXREPLACE(A4:A&"", "[0-9\. ]", ))))/B1))})
spreadsheet demo
Another solution:
=ArrayFormula({"Average";(ArrayFormula(mmult(N(array_constrain(ArrayFormula(IFERROR(SPLIT(A4:A8,","))),MATCH(2,1/(A4:A8<>""),1),5)),sequence(Columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)/mmult(N(array_constrain(if(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))>0,1,0),MATCH(2,1/(A4:A8<>""),1),5)),sequence(columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)))/$B$1})

Google sheet arrayformula join() and split() functions

Does anybody know how to arrayformula this join function?
My formula is not as complex as the example here. ArrayFormula a Filter in a Join (Google Spreadsheets)
It does not contain a filter function, so I'm not sure what from that answer applies and doesn't apply.
I want to array formula this: =if(isblank(B2),,join("," ,B2:I2))
Using the normal way to array something doesn't work:
=ArrayFormula(if(isblank(B2:b),,join(",",B2:b:I2:i)))
Also for splits, I have split(B2, ",")
=ArrayFormula(split(B2:B,",")) does nothing but the first row
Maybe try:
=ArrayFormula(if(len(B2:B), B2:B&C2:C&D2:D&E2:E&F2:F&G2:G&H2:H&I2:I,))
or
=ArrayFormula(substitute(transpose(query(transpose(B2:I),,rows(B2:B)))," ",""))
or, in case you want a space between the concatenated values:
=ArrayFormula(trim(transpose(query(transpose(B2:I),,rows(B2:B)))))
For using split() in arrayformula a workaround can be found here

Resources