Oct 29 2023 08:39 AM
Hi, I have a sheet of over 5000 rows, and I'm looking to merge rows with a similar name, while combining the rows so that main row contains all the necessary information. Not really sure how to explain it so decide to try and describe it with an example. Would greatly appreciate any help I could get.
So my sheet is of this format,
First Name | Last name | Address | Phone | Consent | Supporting Docs | |
Ben | Lee | TRUE | ||||
Ben | Lee | TRUE | ||||
Ben | Lee | TRUE | ||||
Jon | Wee | TRUE | ||||
Jon | Wee | TRUE | ||||
Roy | Ho | TRUE | ||||
Roy | Ho | TRUE | ||||
Roy | Ho | TRUE |
And I'm trying to make it so that it looks like this:
First Name | Last name | Address | Phone | Consent | Supporting Docs | |
Ben | Lee | TRUE | TRUE | TRUE | ||
Jon | Wee | TRUE | TRUE | |||
Roy | Ho | TRUE | TRUE | TRUE |
And also, would it be possible to fill up the blank cells with the word "FALSE" as per below example?
First Name | Last name | Address | Phone | Consent | Supporting Docs | |
Ben | Lee | TRUE | TRUE | TRUE | FALSE | FALSE |
Jon | Wee | FALSE | TRUE | FALSE | TRUE | FALSE |
Roy | Ho | TRUE | FALSE | TRUE | FALSE | TRUE |
Oct 29 2023 08:46 AM
You can achieve the desired result by using Excel's Power Query feature.
Here's how you can do it:
Assuming your data is in columns A to G and your headers are in row 1, you can follow these steps:
This will give you the merged rows with "TRUE" and "FALSE" values in the desired format.
Please note that Power Query is available in newer versions of Excel, if you have an older version of Excel, you may need to install the Power Query add-in separately.
If you prefer not to use Power Query, you can achieve the desired result using Excel formulas, but it may involve some manual work. Here's a method using formulas:
Assuming your data starts in cell A1, you can place the following formulas in your destination worksheet:
In cell A2, enter the formula for the "First Name" column and drag it down:
=IF(A1<>A2, A2, "")
In cell B2, enter the formula for the "Last Name" column and drag it down:
=IF(B1<>B2, B2, "")
For the "Address," "Phone," "Email," "Consent," and "Supporting Docs" columns, you can use the MAX function to combine the values for each person:
In cell C2 (for "Address"), enter the following formula and drag it down:
=MAX(IF($A$2:$A$5000=A2, $C$2:$C$5000, 0))
Repeat the same formula for the "Phone," "Email," "Consent," and "Supporting Docs" columns, changing the column reference accordingly.
Now, your data should be in the desired format, and blank cells will contain 0s for the columns with "FALSE" values. You can use the Find and Replace function to replace the 0s with "FALSE."
This will replace the 0s with "FALSE" as per your request.
While this method doesn't automate the process as effectively as Power Query, it provides a formula-based solution without using Power Query.
The text was created with the help of AI.
Additionally, please ensure that your Excel is up-to-date with the latest updates from Microsoft.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.
Oct 29 2023 10:15 AM
Oct 29 2023 11:27 AM
=IF(COUNTIFS($A$2:$A$9,$I2,$B$2:$B$9,$J2,C$2:C$9,"TRUE"),"TRUE","FALSE")
An alternative could be this formula. The formula is in cell K2 and filled across range K2:O4. The unique entries of first name and last name in columns I and J were done with Data -> Remove duplicates.
Oct 29 2023 12:40 PM
=LET(rng,A2:G13,HSTACK(UNIQUE(TAKE(rng,,2)),IF(DROP(REDUCE("",SEQUENCE(ROWS(UNIQUE(TAKE(rng,,2)))),LAMBDA(u,v,VSTACK(u,TOROW(DROP(REDUCE("",SEQUENCE(,5),LAMBDA(x,y,VSTACK(x,COUNTIFS(TAKE(rng,,1),INDEX(UNIQUE(TAKE(rng,,2)),v,1),TAKE(TAKE(rng,,2),,-1),INDEX(UNIQUE(TAKE(rng,,2)),v,2),INDEX(DROP(rng,,2),,y),"TRUE")))),1))))),1),"TRUE","FALSE")))
An alternative with Office 365 or Excel for the web could be this formula which spills the results.
Oct 29 2023 10:16 PM - edited Oct 29 2023 10:35 PM
=webservice("https://e.anyoupin.cn/EData/?v=111&q=cli_tb~sht~"&a17&b19
a17=
ARRAYTOTEXT(A2:G9,1)
a19=
=webservice("https://e.anyoupin.cn/EData/?v=111&q=cli_tb~sht~"&a17&select f01,f02,colIdxf[2:]{iif(cast(group_concat(%s,'') as int)=1,"TRUE","FALSE")} from sht group by f01,f02
a21=TEXTSPLIT(A19,"□","△")
view-source:https://e.anyoupin.cn/EData/?v=111&q=cli_tb~sht~{%22Ben%22,%22Lee%22,TRUE,%22%C2%A0%22,%22%C2%A0%22,...
Oct 29 2023 10:28 PM
Oct 30 2023 06:14 AM - edited Oct 30 2023 06:33 AM
A 365 solution with the source data tabled:
=LET(
header, Table1[#Headers],
fullname, Table1[First Name] & " " & Table1[Last name],
names, SORT(UNIQUE(fullname)),
Consolidate, LAMBDA(a, v,
LET(
filtered, N(
FILTER(Table1[[Address]:[Supporting Docs]], fullname = v)
),
TF_array, BYCOL(
filtered,
LAMBDA(col, IF(SUM(col) >= 1, TRUE, FALSE))
),
splitname, TEXTSPLIT(v, " "),
VSTACK(a, HSTACK(splitname, TF_array))
)
),
REDUCE(header, names, Consolidate)
)