Forum Discussion

Centaur1's avatar
Centaur1
Regular Visitor
1 year ago
Solved

Add Conditional Column (tag with 0 or 1)

Hello,   I am a novice user of PQ.  I am deleting duplicates and I know PQ keeps the first instance and deletes the 2nd. What I need to do is keep the 2nd.   Not sure exactly how to do this but ...
  • dufoq3's avatar
    dufoq3
    1 year ago

    1.) For future requests - allways provide sample data and expected resuld based on that!

    2.) If you don't know how to do it - read note below my post.

    3.) If you don't know how to use my query also read note below my post.

     

    New sample: Removes duplicates in [Column1] and [Column2] and keep rows where there are no duplicates.

     

    Before

     

    After

     

    let
        Source = Table.FromRows({{"A", 10, 1}, {"A", 10, 2}, {"B", 50, 5}, {"B", 50, 6}, {"C", 600, 8}, {"C", 600, 9}}),
        RemovedFirstDuplicate = Table.Combine(Table.Group(Source, {"Column1", "Column2"}, {{"T", each if Table.RowCount(_) = 1 then _ else Table.Skip(_), type table}})[T])
    in
        RemovedFirstDuplicate