cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dhruvgulati
Helper I
Helper I

difference of two columns

what will be the syntax for list.difference 

col1 col2  output

1       3        1

2      4         2

3                 5

4

5

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use this. Replace Source line completely with your source.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJWitWJVjICskzALGMgC8wwgTFMwYxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    BuffList1 = List.Buffer(#"Changed Type"[Column1]),
    BuffList2 = List.Buffer(#"Changed Type"[Column2]),
    DiffList = List.Difference(BuffList1,BuffList2),
    Result = Table.FromColumns(Table.ToColumns(#"Changed Type")&{DiffList},Table.ColumnNames(#"Changed Type")&{"Result"})
in
    Result

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Use this. Replace Source line completely with your source.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJWitWJVjICskzALGMgC8wwgTFMwYxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    BuffList1 = List.Buffer(#"Changed Type"[Column1]),
    BuffList2 = List.Buffer(#"Changed Type"[Column2]),
    DiffList = List.Difference(BuffList1,BuffList2),
    Result = Table.FromColumns(Table.ToColumns(#"Changed Type")&{DiffList},Table.ColumnNames(#"Changed Type")&{"Result"})
in
    Result

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors