Duplicating/triplicating rows of data - google-sheets

I have these rows:
Alex
Bob
Chris
I need a function to create three rows for each one, in a way it looks like this:
Alex
Alex
Alex
Bob
Bob
Bob
Chris
Chris
Chris
How can I do that?

I believe your goal as follows.
You want to achieve the following conversion using the built-in functions.
From
Alex
Bob
Chris
To
Alex
Alex
Alex
Bob
Bob
Bob
Chris
Chris
Chris
For this, how about this answer?
Sample formula:
=ARRAYFORMULA(TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,SUBSTITUTE("###","#",A1:A3&"#")),"#")))
The flow of above formula is as follows.
Create the base 3 rows using SUBSTITUTE("###","#",A1:A3&"#") as a string.
For example, Alex becomes Alex#Alex#Alex#.
Merge each string of each source rows using TEXTJOIN.
For example, Alex, Bob, Chris becomes Alex#Alex#Alex##Bob#Bob#Bob##Chris#Chris#Chris#.
Split the string using SPLIT.
By this, each value is put to each cell.
Transpose the values using TRANSPOSE.
By this, the result value can be retrieved.
In this case, =TRANSPOSE(ARRAYFORMULA(SPLIT(TEXTJOIN("#",TRUE,SUBSTITUTE("###","#",A1:A3&"#")),"#"))) can be also retrieve the same result.
Result:
Note:
If the source values include #, please modify to other character.
In this case, when a lot of rows are converted, an error related to the limitation might occur. So please be careful this.
References:
SUBSTITUTE
TEXTJOIN
SPLIT
TRANSPOSE

Related

Check for duplicates in Google sheets

hoping someone can help here.
I am simply looking to identify duplicate names in one column and update a drop-down in another. The only caveat to this would be to allow one to pass as unique with the rest being duplicated. I have posted a screenshot as a demo of what I'm looking to achieve.
So in here you will see Bob appearing 3 times, the first should be yes to unique with the other 2 being no.
Name
Unique
Bob
Yes
Charles
Yes
Audrey
Yes
Bob
No
Bob
No
use:
=INDEX(IF(A2:A="";;IF(COUNTIFS(A2:A; A2:A; ROW(A2:A); "<="&ROW(A2:A))=1; "yes"; "no")))

Concatenate Use in Google Sheets (Not in MS-Excel)

I'd like to ask about how to use concatenation formula in Google Sheets (Not in MS-Excel). In Specific, I'd like to Combine Multiple values in Columns to a single value in 1 row. Please let me know your thoughts and suggestions.
Thanks in Advance mates,
Manoj
depends...
you can mostly use just &
=A1&B1
=INDEX(A1:A5&B1:B5&C1:C5)
if you need something advanced try query smash
=QUERY(A:D;; 9^9) << this will collapse all rows of each column into one row
for more about query smash see: https://stackoverflow.com/a/65435321/5632629

Check Similarity String Between Column In Google Sheet

I have a table in the link below:
https://docs.google.com/spreadsheets/d/1EOALaBVzHijUP_8dM1Sr7KTutdTah8b9Q0xDRoNHBLo/edit#gid=0
if the text is split first, then check what do you do? for example "Kebumen District Office" Vs "District Head Office of Kebumen District" Then we need 7x7 columns = 49 columns because we will match for each word words 1-1, 1-2, 1-3, 1-4, 2-1, 2-2.2-3.2-4, etc.
The text in column B is split and then checked for each word with the text in column A. If in column B there are many different words found the text is not similar.
Only I am still confused to make the formula. Please give me the solution sir. Thanks.
The matching patterns are very different in your case and I see no solution based on formulas (regular expressions).
You may need to find articles about fuzzy vlookup.
Here's what I found for google sheets (not tested):
Addon, find fuzzy matches
This problem is common for Excel, there're solutions based on vba.
As I said, the one formula won't solve your task because you have many cases. First example Mc Donald vs McDonald is checked easily with a formula:
= substitute(A, " ", "") = substitute(B, " ", "")
Your next samples are different. You may use some code, but even this won't give the expected results. My suggestion: split the task into small cases and try to solve them separately. Make an investigation or ack a new question for each case.
Your second and 3-d lines are case2. In this case, you need to check all the words in A are also in B. You'll need to try solving it and ask another question if needed. And so on.
Fuzzy matching is definitely the way to go. Different algorithms have different strengths and weaknesses. My suggestion is that you visit the G Suite marketplace and look for Flookup or simply follow this link:
Flookup for Google Sheets
It'll allow you to look for matches ranging from 0% to 100% similarity. The basic formula is:
FLOOKUP(lookupValue, tableArray, lookupCol, indexNum, [threshold], [rank])
Find out more from the official website.
Edit: I'm the creator of Flookup.

How to make multiple cells have the same layout by removing spaces and capitalising

Loading...
I have a pivot table and loads of names with codes next to them but of course some are repeating because there are probably random extra spaces etc. I wondered if there was a fast way to get around this. Maybe by making every single cell have the same number of spaces. Then I would like everything to become upper case.
for example:
dave jim henrys 1233444567
dave jim henrys 1233444567
should be:
DAVE JIM HENRYS 1233444567
DAVE JIM HENRYS 1233444567
And in my pivot table should be:
DAVE JIM HENRYS 1233444567
Can someone please tell me how to so that
To your source data (then refresh PT), please try applying:
=UPPER(TRIM(A1))

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(...))

Resources