Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
newbie_2023
New Member

Advanced Filter | Power Query

I am trying to find an efficient way to filter a data set using powerquery.  I need to filter out all rows representing a company only when there is no data in another column. But I need to retain all the rows of a company when there is at least one row of data in that column. So for the below table, I need to filter out all rows of Company B as it does not have any data in the "Descr" column. But I need to retain all rows of Company A (including those where the Descr column is empty) and Company C.

 

newbie_2023_0-1698892964164.png

 

I am currently using a two-step process. The first step involves finding companies like A and C by filtering the Descr column for non-null values and then creating a company list (after removing the duplicates). Then I apply inner join as seen below to filter out Company B. 

 

newbie_2023_1-1698893235774.png

 

Is there a straightforward way to perform this filter?

 

Thank you.

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewStep=Table.Combine(Table.Group(YourTable,"Company Name",{"n",each if List.NonNullCount([Descr])=0 the #table(0,{}) else _)})[n])

View solution in original post

2 REPLIES 2
newbie_2023
New Member

Thank you. It did work. But it does take time for a large data set over 100K rows. 

wdx223_Daniel
Super User
Super User

NewStep=Table.Combine(Table.Group(YourTable,"Company Name",{"n",each if List.NonNullCount([Descr])=0 the #table(0,{}) else _)})[n])

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors