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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vshala1
New Member

Remove all rows after specific row in Power Query

Hi guys,

 

I have a very tricky question. 

 

Lets assume the following data table:

 

No    Name    Forname   ...

1       Morgan   John

2       Griffin      Peter

3       Johnson  John

4       ...              ...

5       ....             ...

 

Now I want to get all rows after "3 Johnson John". Problem being is that this might change in the next query dynamically. I have another table with just one entry which would be my row filter criteria with just:

 

3   Johnson    John

 

This I would like to use as a parameter for the filter process of the big table.

 

How can I search the whole table with my row filter criteria and output all values after this specific entry in power query?

 

I'd love to get some ideas from you guys.


Regards.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @vshala1 

 

Please see if solution in attached file is useful

 

I named the table which contains rowfilter criteria as "RowFilter"

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLNL0pPzAMyvPIz8pRidaKVjIAc96LMtLRMkHBAaklqEVjcGKqoOB9FuQmQE1WalAmkHIsz08BipkCOR2Ix2FygXGIm0IRYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [No = _t, Name = _t, Forname = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"No", Int64.Type}, {"Name", type text}, {"Forname", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
Rowstoskip = Table.SelectRows(#"Added Index",each [No]=RowFilter[No]{0} and [Name]=RowFilter[Name]{0} and[Forname]=RowFilter[Forname]{0} )[Index]{0},
Custom1 = Table.Skip(#"Added Index",Rowstoskip)
in
Custom1

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @vshala1 

 

Please see if solution in attached file is useful

 

I named the table which contains rowfilter criteria as "RowFilter"

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLNL0pPzAMyvPIz8pRidaKVjIAc96LMtLRMkHBAaklqEVjcGKqoOB9FuQmQE1WalAmkHIsz08BipkCOR2Ix2FygXGIm0IRYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [No = _t, Name = _t, Forname = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"No", Int64.Type}, {"Name", type text}, {"Forname", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
Rowstoskip = Table.SelectRows(#"Added Index",each [No]=RowFilter[No]{0} and [Name]=RowFilter[Name]{0} and[Forname]=RowFilter[Forname]{0} )[Index]{0},
Custom1 = Table.Skip(#"Added Index",Rowstoskip)
in
Custom1

Regards
Zubair

Please try my custom visuals

@vshala1 

 

Bascially,

 

1) we add index column to identify row number

2) get the index number for matching row

3) skip the rows upto that index number


Regards
Zubair

Please try my custom visuals

Thank you so much! I am nearly there I think. The only thing is that it says "Expression.Error: The name 'RowFilter' wasn't recognized. Make sure it's spelled correctly." although I named my table "RowFilter".

 

Any idea?


Found it! Your solution works!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.