Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi,
In the example below I want to filter those Customers that have a Discovery and Project Work. I want to filter out those Customers that do not have a Discovery. So for the example below I would like to remove rows 4 and 5. Is this possible, if so can you please tell me how? I have tried numerous approaches but none succesfully.
Many thanks
| Number | Customer | Project | Project Type |
| 1 | A | 1111 | Discovery |
| 2 | A | 1112 | Project Work |
| 3 | A | 1113 | Project Work |
| 4 | B | 2222 | Project Work |
| 5 | C | 3333 | Project Work |
| 6 | D | 4444 | Discovery |
| 7 | D | 4441 | Project Work |
Solved! Go to Solution.
In the Query Editor (Power Query) it can be done as follows.
Steps:
Generated code, starting with the first step after your last step (which I called PreviousStep, so adjust with the name of your last step):
#"Sorted Rows" = Table.Sort(PreviousStep,{{"Customer", Order.Ascending}, {"Project Type", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1),
#"Merged Queries" = Table.NestedJoin(#"Added Index1",{"Index"},#"Added Index1",{"Index.1"},"Previous",JoinKind.LeftOuter),
#"Expanded Previous" = Table.ExpandTableColumn(#"Merged Queries", "Previous", {"Customer"}, {"Previous.Customer"}),
#"Sorted Rows1" = Table.Sort(#"Expanded Previous",{{"Index", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(#"Sorted Rows1", "Keep", each if [Project Type] = "Discovery" then true else (if [Customer] <> [Previous.Customer] then false else null)),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Keep"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Keep] = true)),
#"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows",{"Index", "Index.1", "Previous.Customer", "Keep"})
in
#"Removed Columns1"n
In the Query Editor (Power Query) it can be done as follows.
Steps:
Generated code, starting with the first step after your last step (which I called PreviousStep, so adjust with the name of your last step):
#"Sorted Rows" = Table.Sort(PreviousStep,{{"Customer", Order.Ascending}, {"Project Type", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1),
#"Merged Queries" = Table.NestedJoin(#"Added Index1",{"Index"},#"Added Index1",{"Index.1"},"Previous",JoinKind.LeftOuter),
#"Expanded Previous" = Table.ExpandTableColumn(#"Merged Queries", "Previous", {"Customer"}, {"Previous.Customer"}),
#"Sorted Rows1" = Table.Sort(#"Expanded Previous",{{"Index", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(#"Sorted Rows1", "Keep", each if [Project Type] = "Discovery" then true else (if [Customer] <> [Previous.Customer] then false else null)),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Keep"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Keep] = true)),
#"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows",{"Index", "Index.1", "Previous.Customer", "Keep"})
in
#"Removed Columns1"n
Thank you, took me a while to get my head round it, but that works.
Victoria
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 23 | |
| 18 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 51 | |
| 44 | |
| 43 | |
| 39 | |
| 32 |