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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors