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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Filter Column Based On Value From Another Column In Power Query

I have a dataset that looks like this:

 

IndexBalanceDateOrder NumberOrder Line
166/1/202200
236/16/202200
327/6/202200
4-17/18/202200
5-57/20/202200
6-65/25/20221234561
716/8/202200
8157/8/202200
9217/9/202200
10277/20/202200

 

I want to filter the table so it includes all rows after and including the row where [Order Number] = 123456 and [Order Line] = 1. My thought is if there is a way to look up the index value for that row, then filter on the Index column where [Index] is greater than that value.

 

So in this example, look up [Order Number] = 123456 and [Order Line] = 1 and return [Index] = 6. Then filter on [Index] >= 6. Is there a way to do this in Power Query (not DAX)? Or is there a better way to filter all rows after and including the row that meets the criteria of one of the columns? The data is such that there would never be more than 1 row with the same order number/order line combination.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found a solution that worked for me.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7LDQAhCATQXjxrFBQ/tRj7b2MdzJ7goBl5hszegUIMHSdT5sJ8Y9Fz4g541YfdKgSTkR1sNyVSpWlZwKLMxTIaJVySWX4mrk0wJP0zNKGcs38C335HF5q/cssqIfLwy50P", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, Balance = _t, Date = _t, #"Order Number" = _t, #"Order Line" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", Int64.Type}, {"Balance", Int64.Type}, {"Date", type date}, {"Order Number", Int64.Type}, {"Order Line", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Order Number] = 123456) and ([Order Line] = 1)),
    Index = #"Filtered Rows"{0}[Index],
    #"Filtered Rows1" = Table.SelectRows(#"Changed Type", each [Index] >= Index)
in
    #"Filtered Rows1"

 

First I filtered to the specific row where Order Number = 123456 and Order Line = 1. Then I used #"Filtered Rows"{0}[Index] to select the Index column value for that row. Then I referenced back to the table in step #"Changed Type" before I filtered to the order, and filtered on the Index column to values greater than the value returned by the Index = #"Filtered Rows"{0}[Index] step. There may be other or better ways to accomplish this, but it worked for my scenario.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

I found a solution that worked for me.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7LDQAhCATQXjxrFBQ/tRj7b2MdzJ7goBl5hszegUIMHSdT5sJ8Y9Fz4g541YfdKgSTkR1sNyVSpWlZwKLMxTIaJVySWX4mrk0wJP0zNKGcs38C335HF5q/cssqIfLwy50P", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, Balance = _t, Date = _t, #"Order Number" = _t, #"Order Line" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", Int64.Type}, {"Balance", Int64.Type}, {"Date", type date}, {"Order Number", Int64.Type}, {"Order Line", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Order Number] = 123456) and ([Order Line] = 1)),
    Index = #"Filtered Rows"{0}[Index],
    #"Filtered Rows1" = Table.SelectRows(#"Changed Type", each [Index] >= Index)
in
    #"Filtered Rows1"

 

First I filtered to the specific row where Order Number = 123456 and Order Line = 1. Then I used #"Filtered Rows"{0}[Index] to select the Index column value for that row. Then I referenced back to the table in step #"Changed Type" before I filtered to the order, and filtered on the Index column to values greater than the value returned by the Index = #"Filtered Rows"{0}[Index] step. There may be other or better ways to accomplish this, but it worked for my scenario.

Mannai
Helper I
Helper I

Refer to this it may helps you 

M Query 

Anonymous
Not applicable

Yes you can with lookupvalue in dax

 

Anonymous
Not applicable

@Anonymous I need to do this in Power Query, not using DAX

Mannai
Helper I
Helper I

I dont know if i understanding your example but you want to get only the rows where order line is equals to 1 ?

Anonymous
Not applicable

@Mannai I want to return all rows after and including the row where Order Number = 123456 and Order Line = 1. In this example, row 6 is the row where Order Number = 123456 and Order Line = 1, so I need to return rows 6, 7, 8, 9, and 10.

 

I need to dynamically return the row where Order Number = 123456 and Order Line = 1. So if that is row 5, then I need to return rows 5, 6, 7, 8, 9, 10. If that row is 2, then I need to return rows 2, 3, 4, 5, 6, 7, 8, 9, 10. Etc.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.