PQ question - remove row

scott_86_

New Member
Joined
Sep 27, 2018
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi,

Below is a sample data set (apologizes, I am unable to load a sample mini-sheet) of a much large dataset (with more coloumns) I am using.

My goal: For a specific 'training' value ('Heights' in the example), if a 'name' ('Scott' in the example) has both a 'Completed' and 'Approved' row, then remove the 'Approved' row.

I have a hunch this may be able to be achieved through the 'group by' and 'merge query' functions; however, I've had no luck so far trying this.

Is anyone able to help with some steps to achieve the above goal? I'm trying to learn steps and M code amending rather that asking for the code so I can trouble shoot queries in future. Thanks!

1725861431465.png
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,
for example

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    cols = {Table.ColumnNames(Source)} & {{"Approved", "Completed"}},
    Grouped = Table.Combine(Table.Group(Source, List.FirstN(cols{0},2), {{"x", 
              each 
              if List.ContainsAll(Table.Column(_,cols{0}{2}), cols{1}) 
              then Table.SelectRows(_, each Record.Field(_, cols{0}{2}) = cols{1}{1} ) 
              else _ }})[x])
in
    Grouped

Regards
 
Upvote 1
Solution

Forum statistics

Threads
1,223,880
Messages
6,175,155
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top