Forum Discussion
Kailef
Mar 11, 2023Copper Contributor
Excel 365 Power Query Help extracting unique data
So I have already set up a power query in a sharepoint folder to pull data from a specific sheet. I have "Column 1" and "Column 2". Each column contains a list of names. Some of the names will ap...
SergeiBaklan
Mar 11, 2023Diamond Contributor
As variant that could be manual script like
let
Source = Excel.CurrentWorkbook(){[Name="tblNames"]}[Content],
Column1 = Source[Column1],
Column2 = Source[Column2],
Column3 = List.RemoveMatchingItems( Column1, Column2 ),
Column4 = List.RemoveMatchingItems( Column2, Column1 ),
/*
if only unique values to keep, above is like
Column3 = List.Distinct(
List.RemoveMatchingItems( Column1, Column2 ) ),
Column4 = List.Distinct(
List.RemoveMatchingItems( Column2, Column1 ) ),
*/
// Both result1 and result 2 return the same,
// select one on your choice
result1 = Table.FromColumns(
{Column1, Column2, Column3, Column4},
{"1st", "2nd", "Only 1st", "Only 2nd"}
),
result2 = #table(
type table
[
1st = text,
2nd = text,
#"Only 1st" = text,
#"Only 2nd" = text
],
List.Zip( {Column1, Column2, Column3, Column4} )
)
in
result2
which returns
Kailef
Mar 11, 2023Copper Contributor
Thanks everyone. Really appreciate all the help.
- SergeiBaklanMar 11, 2023Diamond Contributor
Kailef , you are welcome