Dec 24 2023 02:14 AM
I have attached a sample file. Column A contains the cities. Some of them have same city names but their state names are different(column M). I want to add State abbreviation (Column N) to only those cities which are duplicates. For Example if AKRON city is present in Colorado and Indiana, I want Akron Colorado to be Named as AKRON-CO and Akron Indiana to be named as AKRON-IN.
Any help would be greatly appreciated.
Dec 24 2023 02:40 AM
=IF(COUNTIF($A$2:$A$962,A2)>1,A2&"-"&N2,A2)
This is the formula in cell Q2 which combines PHYSICAL CITY and PHYSICAL STATE if the PHYSICAL CITY is a duplicate. The formula is filled down column Q.
Dec 24 2023 02:45 AM
A Power Query option attached
let
Source = Table,
GroupedRows = Table.Group(Source, {"PHYSICAL CITY"},
{"DATA", each
Table.AddColumn(_, "PHYSICAL CITY-STATE", (o)=>
if Table.RowCount(_) > 1 then Text.Combine({o[PHYSICAL CITY], o[PHYSICAL STATE]}, "-") else null
),
type table
}
),
CombineTables = Table.Combine(GroupedRows[DATA])
in
CombineTables
Dec 24 2023 06:58 AM
Dec 24 2023 08:57 AM
Dec 24 2023 08:22 PM
Dec 24 2023 11:12 PM
i hope it help with array trick