Transpose single column to array of unique rows - excel

I'm trying to get a list of values that contain duplicates into unique rows.
Column A
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Column A
Column B
Column C
Cell 1
Cell 1
Cell 1
Cell 2
Cell 2
Cell 2
Cell 3
Cell 3
I've tried using
=TRANSPOSE(UNIQUE(A1:A3,TRUE,TRUE))
But any combination of the formula removes the duplicates and I want to maintain them.

with MakeArray:
=LET(
rng,A1:A8,
u,UNIQUE(rng),
MAKEARRAY(
ROWS(u),
MAX(COUNTIF(A1:A8,u)),
LAMBDA(a,b,
IF(COUNTIF(A1:A8,INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a))>=b,
INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a),
""))))
This will expand automatically to any number. It will also put the ones with the most duplicates at the top so it is an inverted pyramid:

Alternatively, you can try:
Formula in C1:
=IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),"")
Or, with a build-in sort function:
=SORT(IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),""),1)

Related

excel/google sheet - combining 2 column into 1 (vertically)

what is the formula to combine 2 column into 1?
(sheet link included : here)
for example :
Column A
Column B
Cell 1
Cell 2
Cell 3
Cell 4
Cell 5
Cell 6
become :
Combined
(with the spacing blanks included)
Cell 1
Cell 3
Cell 4
Cell 6
Cell 2
Cell 5
this is the database primary sheet, so the plan is i will load/link from this database sheet to another sheet (plus in case i have another cell to add between, it will sorted out automatically)
i try arrayformula({A:A;B:B}) but it tells me to add another row ?
help please
formula tried :
arrayformula,
flatten,
(it tells me to add another row?)
unique
(it overwrite the doubles? and remove blank space?, i need the text to be it as it is)
Try the following formula for raw materials. Then use same formula for packaging and change column references.
={FILTER(A:A,A:A<>"");" ";FILTER(E:E,E:E<>"")}
Edit: To include blank cells try this formula-
={C1:INDEX(C1:C,MATCH("zzz",C1:C));" "; G1:INDEX(G1:G,MATCH("zzz",G1:G))}

How to concatenate range of cells in a row

I have a simple Excel spreadsheet with a single row and 4 columns. I'm trying to concatenate 3 cells in the row together using a range instead of specifying all 3 cells explicitly (for times where I need to concatenate several cells).
The data is as follows:
[A1] 5
[B1] 6
[C1] 7
[D1] =CONCATENATE(A1:C1)
The result I get in D1 is #VALUE instead of what I'm looking for, which would be 567.
Is there a way to accomplish this using a range?
If you have Office 365:
=CONCAT(A1:C1)
If not
=A1 & B1 & C1
or
=CONCATENATE(A1,B1,C1)
A helper column can gradually build the string, by concatenating above row with the next value.
A B B (formula)
1 h h =A1 Initial value
2 e he =B1&A2 Concatenate above cell with next value
3 l hel =B2&A3 Copy formula downwards, it should auto-increment.
4 l hell =B3&A4
5 o hello =B4&A5
(Similar question: Concatenate range in Excel with formulas)

Skip a chosen ratio of cells in Excel

I have tried to:
Take item 1 from List A and put it in row 1.
Then put item 2 from List A in row 11.
Then put item 3 from list A in row 21 (etc.)
Then I tried to do the same with List B but:
Item 1 from List B to row 2.
Item 2 from List B to row 12.
Item 3 from List B to row 22 (etc)
How do I tell Excel to fill the cells in this ratio?
I have a solution but it involves inserting a column before both columns A & B
If you insert a column and put 1 in A1 and then the formula =A1+10 in cell A2 and fill down, you will have your row ratio 1,11,21,31. Do the same for column B but start with 2 in cell C1 and enter the formula =C1+10 in C2 and fill down.
Now that you have the destination row number next to your data, you can use a vlookup to pull the correct data into the correct row.
cell E1 =iferror(vlookup(Row(),$A$1:$B$20,2,false),"")
cell F1 =iferror(vlookup(Row(),$C$1:$D$20,2,false),"")
or you could combine them in the same column using
=iferror(vlookup(Row(),$A$1:$B$20,2,false),iferror(vlookup(Row(),$C$1:$D$20,2,false),""))

Group 2 columns and sum values for another column

I have the following problem: I need to group data and perform a sum in another column in libreoffice calc/excel spreadsheet, just like a group by would do in SQL
In the following example, I would like the cells A26, A27 to become one line, and cell C26 should be the sum of the 2 rows.
Try on E26 cell the formula =($A26 & $B27) (Or =($A26 & (-$B27)) if you want a dash between A26 and B27).
And on F26 cell =($C26+$C27) for the sum of rows.
Copy/Paste for the other cells of each col

Creating unique ID numbers for duplicate Excel rows

I have an Excel spreadsheet with multiple columns. I'd like to automatically add unique ID numbers (starting in cell A2) to duplicate values in column D (starting at D2). Any way to make the spreadsheet look like below? Thanks.
Column A Column D
1 3
1 3
2 Bard
2 Bard
3 4ton
3 4ton
3 4ton
In A1 enter 1
In A2 enter:
=IF(D1=D2,A1,A1+1)
and copy down.
It's not clear on whether your data table has column header labels or not but this formula should not make a difference beyond having to pre-populate A1 if there is no column header label.
In A2 use this formula,
=IFERROR(INDEX(A$1:A1, MATCH(D2, D$1:D1, 0)), MAX(A$1:A1)+1)
Fill down as necessary. Your results should resemble the following.
        
While your column D was sorted, that is not a requirement with this formula.

Resources