PQ question - remove row

scott_86_

New Member
Joined
Sep 27, 2018
Messages
45
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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,225,726
Messages
6,186,674
Members
453,368
Latest member
xxtanka

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