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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Kraius
Frequent Visitor

filter nested table rows

This is hopefully an easy one.  I'm working with Power Query (or M, i guess) in the Desktop software and am importing a bunch of spreadsheets (with same schema) into some tables.  One of the tabs in the sheet has some useful info in the first 30 rows and then just a ton of junk for the next few thousand rows that i'll never need (with a bunch of #N/A data too, which breaks my excel data connector).  I don't own this data so it's kinda a manual effort to drop the data out of the tab pre-import into BI. 

 

I know M/Power Query has the functions for FirstN rows and the like, but i can't figure out if there is a way to apply it to a table nested within a row in the data (before you expand that nested table into new columns).  Ideally, I'm hoping there is a way to tell Power BI to "take this sheet/tab from this xlsx, crop it down to just X rows, expand it into working rows/columns and do fancy transforms".  Can you somehow nest a FirstN function into an ExpandColumns function?

1 REPLY 1
v-caliao-msft
Microsoft Employee
Microsoft Employee

@Kraius,

 

 Please refer to the link below to see how to get dynamic Top N rows in Power Query.

1. Source = Csv.Document(File.Contents("NameRemoved.csv"),null,",",null,1252)

2. #"FilteredRows" = Table.SelectRows(Source, each Text.Contains([Column1], "Daily Usage")),

3. #"Position of Daily Usage" = Table.PositionOf(Source, FilteredRows {0}),

4. #"TopRemoved" = Table.Skip(Source, (#"Position of Daily Usage" + 1)),

5. #"First Row as Header" = Table.PromoteHeaders(#"TopRemoved"),

 

http://blogs.adatis.co.uk/danevans/post/Dynamic-Top-N-rows-in-Power-Query

 

Regards,

Charlie Liao

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.