How to transpose rows into columns of contact details without mixing them up? (Google Sheets) - google-sheets

I have a data set of contact details where the emails and their names are scattered in rows, I would like to list them in 2 nice columns. I've tried using "paste special" and use this code below, but none of them worked.
This is how it looks like:
I've tried this code, but it only applies to one row, whereas I want to apply it to all rows and columns.
=transpose(A2:R2)
and
=transpose (A2:R300)
Both don't work. I hope somebody can help me with this, I'd really appreciate it. Thanks in advance!

It looks that you are using the wrong terms so you are using the wrong functions.
Apparently you have a cell with data separated by spaces and break lines and you want to have each email and name on it's own cell, having emails on one column and names on the next column.
One way to achieve that, first replace the separating spaces by using a character like | and the break lines by another different character like $.
Note: Some people use Unicode characters that are very unlikely to appear like ♦, ❤.
To do the above for break lines you could use FIND and REPLACE (Ctrl + H) or function formulas like REGEXREPLACE, SUBSTITUTE, and maybe others. As there are spaces used both as word separators and values separators, FIND and REPLACE can't be used easily. For a single cell, maybe the easier way is to insert the name/email separator manually.
Then separate the cell data. To do this you could use a formula function like SPLIT or Data > Separate values into columns.
Another way is by using Google Apps Script and JavaScript string handling methods but basically the algorithm is the same.
Related
How to split this complex string into 3 columns and 50 rows using Google sheet script
Google Apps Script: Create new rows for cells that contain commas
Google Sheets: string to columns and rows

Related

Problem splitting "matrix"-string into actual matrix in Google sheets

I want to enter a matrix into a single cell (lots of variable => tedious to enter one entry/cell) i chose the format x_1, y_1; x_2, y_2; ... and would like to split this up so I can access them easily for various functions. My first idea was to firstly split them up with the ; delimiter to get a row of x_i, y_i cells and then split that row into two rows, one with x_i and one with y_i. The first part worked out but I'm having trouble doing the second part effectively.
first formula: (in 'split 1' sheet)
=split(data!F2; ";")
second formula:
=transpose(split(filter('split 1'!B1:Z1; len('split 1'!B1:Z1)); "," ) )
The second formula only works for the first cell but doesnt give me anything else, i tried adding arrayformula() to it but it still doesnt work, what am I doing wrong? (I know I could just apply the function to a single cell and then copy it to the other cells but that seems like a very bad solution that easily breaks)
Also, I currently store the rows in separate sheets, I don't really need the data I just want to put them into a few functions. Is there a way to do this in a single cell so I just can write =function(expression for the split)?
#EDIT
Im trying to make a recipe calculator (like myfitnesspal) using sheets, heres a link to an editable copy of it: https://docs.google.com/spreadsheets/d/13hKVbnot6PSangmooprs7vMwrP5Txj5_ddMc9Xgowvs/edit?usp=sharing
Try this:
=ARRAYFORMULA(TRIM(SPLIT(TRANSPOSE(SPLIT(G2; ";")); ",")))

Combining REGEXEXTRACT and SUBSTITUTE in Google Sheets Formula

I'm extracting text from filename cells into separate metadata field cells. So far I have done this successfully using the REGEXTRACT formula, as seen below.
=REGEXEXTRACT(A1, "TILEABLE|ROOM|MAIN|FLOORSHOT|SWATCH|ANGLED")
However some metadata fields that include multiple words require that a space or other character be placed between words. I'm trying to figure out how to use SUBSTITUTE or REPLACE in conjunction with REGEXTRACT to find a phrase and replace it with a version with something different. Ex. Replace "TOPDOWN" with "Top Down" or replace "1TO1" with "1-to-1).
Depending on your purpose one formula might be better than other. If you want to list in a column the substituted values of this string you could chain the number of phrases you want using SUBSTITUTE and REGEXTRACT.
This will return all the phrases you are looking for and substitute them to then use the formula TRANSPOSE to take this range and display it in a columns (as it normally would be displayed in a row and only a single value). This is a simple example:
=TRANSPOSE({SUBSTITUTE(REGEXEXTRACT(A1,"TOPDOWN"),"TOPDOWN","Top Down"),SUBSTITUTE(REGEXEXTRACT(A1,"SHIRTS"),"SHIRTS","Shirts1")})
try:
=SUBSTITUTE(SUBSTITUTE(REGEXEXTRACT(A1,
"TOPDOWN|1TO1|TILEABLE|ROOM|MAIN|FLOORSHOT|SWATCH|ANGLED"),
"TOPDOWN", "Top Down"),
"1TO1", "1-to-1")

Google Sheets Cross Join Function Tables with More than Two Columns

The crossJoin function posted by #Max Makhrov from the below thread works almost completely for what I was hoping to achieve. It was in response to cross joining two columns and I tried joining two tables, one with two columns and one with five columns. It works but only partially.
The delimiter of the column data is stuck as comma ",". This could be problematic for values with commas. The delimiter variable in the function only defines the two ranges being joined.
If the column being joined is a date for example, it seems to extend out the full date text inclusive of time zone and fixed as text. Is there a way to allow for it to be non-text to be formatted? Even when it's parsed using the split() function it's definitely still text.
Result of JOIN is longer than the limit of 50,000 characters
Below is a link to the example input and output. The first output example is a standard cross join. The other is the actual desired output which filters for any data rows where the date in column 5 is greater than or equal to the date in column 2.
https://docs.google.com/spreadsheets/d/1FGS8lYyy60AH49Qyug8Uxaey5jxDksihOks7ll8Hq10/edit?usp=drivesdk
Your spreadsheet is View Only, so i can't demo it there, but try this. On the demo sheet, start a new tab, then put this formula in cell A2.
Happy to walk you through it a bit if it works. Otherwise, maybe make the sample editable so i can troubleshoot w/ you in the same place?
=ARRAYFORMULA(QUERY({HLOOKUP({"A","B"},{"A","B";Sheet1!A5:B},SEQUENCE(COUNTA(Sheet1!D5:D)*COUNTA(Sheet1!A5:A),1,0)/COUNTA(Sheet1!D5:D)+2),HLOOKUP({"D","E","F","G"},{"D","E","F","G";Sheet1!D5:G},MOD(SEQUENCE(COUNTA(Sheet1!D5:D)*COUNTA(Sheet1!A5:A),1,0),COUNTA(Sheet1!D5:D))+2)},"where Col2>=Col5"))

Stacking multiple columns on to one?

I am using Google SpreadSheet, and I'm trying to have multiple sheets containg a list of words. On the final sheet, I would like to create a summative list, which is a combination of all the values in the column. I got it sort working using =CONCATENATE() , but it turned it into a string. Any way to keep it as a column list?
Here is an example as columns:
Sheet1
apple
orange
banana
Sheet2
pineapple
strawberry
peach
FinalSheet
apple
orange
banana
pineapple
strawberry
peach
Updated Answer
I was right there is a much better solution. It's been posted below but I'm copying it here so it's in the top answer:
=unique({A:A;B:B})
Caveat: This will include one blank cell in certain scenarios (such as if there's one at the end of the first list).
If you're not concerned with ordering and a tailing blank cell a simple sort() will clean things up:
=sort(unique({A:A;B:B}))
Otherwise a filter() can remove the blanks like so:
=filter(unique({A:A;B:B}),NOT(ISBLANK(unique({A:A;B:B}))))
The following is the old deprecated answer
I'm confident that this is "The Wrong Way To Do It", as this seems such an absurdly simple and common task that I feel I must be missing something as it should not require such an overwrought solution.
But this works:
=UNIQUE(TRANSPOSE(SPLIT(JOIN(";",A:A,B:B),";")))
If your data contains any ';' characters you'll naturally need to change the delimiter.
The basic way, is just to do it as arrays like so
={A1:A10;B1:B10...etc}
The problem with this method, as I found out is that its very time consuming if you have lots of columns.
I've done some searching around and have come across this article:
Joining Multiple Columns Into One Sorted Column in Google Spreadsheets
The core formula is
=transpose(split(arrayformula(concatenate(if(len(A:Z)>0,A:Z&";",""))),";"))
Obviously you'd replace the A:Z to whatever range you want to use.
And if you want to do some sorting or removing duplicates, you'd simply wrap the the above formula in a SORT() and/or UNIQUE() method, like so..
=sort(unique(transpose(split(arrayformula(concatenate(if(len(A:Z)>0,A:Z&";",""))),";"))))
Hope this helps.
Happy coding everyone :)
You can use this:
=unique({A1:A;B1:B})
Works perfect here!
The unique() function gets rid of blank spaces, but wasn't helpful for me because some of my rows repeat. Instead I first filter the columns by len() to remove blank cells. Then I combine the columns together in the same way.
={filter(A:A, len(A:A)); filter(B:B, len(B:B))}
Much more simple:
={sheetone!A2:A;sheettwo!A2:A}
Use flatten, e.g. flatten(A1:B2). More details in this article.
If the 2d range is not in one piece, one can be created first with the ampersand or similar techniques. Afterwards flatten can be called on the resulting 2d range. The below example is a bit overkill but it is nice when working with dynamic 2d ranges, where the basic solution can't be easily used.
flatten(ARRAYFORMULA(SPLIT(ARRAYFORMULA(A1:A2&";"&C3:C4), ";")))
The article shows also how to easily unflatten a range using the, as well undocumented, skipping clause in a query.
=TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,TRANSPOSE(A:C),TRANSPOSE(D1:D5)),"#",FALSE,FALSE))
use a preferred delimiter absent in the data (instead of #) if needed
the first 1 (TRUE) parameter means IGNORE EMPTY, which is very important in this case..
the A:C and D1:D5 are the ranges to combine
all values remain there - not using UNIQUE
Try using your CONCATENATE argument with
=ArrayFormula(EXPAND(...))

Exporting values of unchecked items in Google Forms checklist

Using Google Forms checkboxes to collect survey responses into a Sheets doc, I find that I can only get the values of checked lines to fill the spreadsheet.
I'm trying to get the unchecked CheckBox values to fill a different cell in the spreadsheet as well, has anyone found out a way to do this?
I'd appreciate any help!
I have a way with spreadsheet formulas.
The drawbacks are the necessities of
manual input of all possible options
copying and pasting a formula for each response (can be done in advance, but if not enough formulas are pasted for the number of responses, the sheet will break)
An ideal solution would automatically detect all possible responses, and could theoretically accept an infinite number of responses without breaking and needing maintenance.
With that said, he's an example of what I suggest:
Google Sheet
Google Form
All possible options on the form must be typed into cells A2:A
cells B2:B show comma+spaces if the corresponding cell in A2:A is not blank, with =arrayformula(if(isblank(A2:A),"",", ")). These commas and spaces are needed later in a concatenate().
Raw data from the Form Responses spreadsheet was brought into D2:E with =arrayformula('Form Responses 1'!A2:B)
G2:G holds the important formulas. They must be copied and pasted to each individual cell for each row.
First, all possible responses in $A$2:$B are filtered based on if the cell in column A can be found in the text in column E.
=filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2))))
Next, some error catching. I added an iferror() to catch a "N/A, no results found in filter evaluation", and an if(isblank(),"",) to catch if no timestamp is in column D meaning no response was recorded in this row.
=if(isblank(D2),"",iferror(filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2)))),""))
Finally, do a concatenate() to pull the values and the comma+spaces all into one string inside one cell.
=concatenate(if(isblank(D2),"",iferror(filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2)))),"")))
Oh, and if you don't like the comma+space being the last characters in the string, in J2:J I did a =arrayformula(iferror(left(H2:H,len(H2:H)-2),"")) which cuts off the last 2 characters of the string in column H.
If I come up with a better solution, I'll let you know. It's an interesting puzzle to solve.

Resources