Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
LP280388
Resolver II
Resolver II

Compare two text columns and write the difference in the third column in PowerQuery

Hi Team,

 

I have columns as below (excluding last column which the output Im trying to fetch) : 

Emp IDMgr IDEmployee StatesManager StatesStates Missing
G1G0A, B, C, DA, B, DC
G2G0X, Y, Z, E, FY, Z, FX, E

 

Im trying to add a new column at the end "States Missing" with the values that are not present in Manager states compared to Employee states.  Im trying to do this powerquery.

 

Kindly help

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@LP280388 

you can try this to create a new column in PQ

 

= Table.AddColumn(#"Changed Type", "Custom", each
[a=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Remove([Employee States]," ")),
b=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Remove([Manager States]," ")),
c=List.Difference(a,b),
d=Text.Combine(c,",")
][d])

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@LP280388 

you can try this

 

= Table.AddColumn(Source, "Custom", each
[a=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Trim([Employee States]," ")),
b=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Trim([Manager States]," ")),
c=List.Difference(a,b),
d=Text.Combine(c,",")
][d])

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@LP280388 

you can try this to create a new column in PQ

 

= Table.AddColumn(#"Changed Type", "Custom", each
[a=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Remove([Employee States]," ")),
b=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Remove([Manager States]," ")),
c=List.Difference(a,b),
d=Text.Combine(c,",")
][d])

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu , Thank you. It did work with the sample data I provided. Thanks for the same. 

In my original data i have company names with space included like the below.  May I know how can i modify this query to suit this.

Employee States
Am ciat, Brian be, Ceat kod, Doug fen

@LP280388 

you can try this

 

= Table.AddColumn(Source, "Custom", each
[a=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Trim([Employee States]," ")),
b=Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(Text.Trim([Manager States]," ")),
c=List.Difference(a,b),
d=Text.Combine(c,",")
][d])

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors