cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
edhans Super Contributor
Super Contributor

Reference a column to filter a nested table in Power Query?

I am trying to filter a column in a nested table by a column in the query that holds the nested table. 

In the [All Rows] column are nested tables that have the year and main account number and amounts. I only want the amounts that are >= the [Year] column. So you can see what I tried to do:

 

(ignore that both the column I am filtering and the column I am filtering by are both called "Year" as that isn't the problem. Renaming one doesn't fix it)

 

I am getting "Expression.Error: A cyclic reference was encountered during evaluation." which I kinda get. I know how to get the results I want by expanding the column and doing some boolean logic, but I'd really like to get the results inside the nested table before expanding. Any suggestions on the right syntax for this, or is it simply not possible for a nested table to reference an external column from the table the nested table is in?

 

20190924 10_59_59-Years - Power Query Editor.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Reference a column to filter a nested table in Power Query?

@edhans 

 

If i understand the problem correctly

 

each let myyear=[Year]
in
Table.SelectRows([All Rows], each [Year] >= myyear))
Try my new Power BI game Cross the River

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: Reference a column to filter a nested table in Power Query?

@edhans 

 

If i understand the problem correctly

 

each let myyear=[Year]
in
Table.SelectRows([All Rows], each [Year] >= myyear))
Try my new Power BI game Cross the River

View solution in original post

AnkitBI Established Member
Established Member

Re: Reference a column to filter a nested table in Power Query?

@Zubair_Muhammad 

Was thinking around the same. Thanks for the learnings 🙂

edhans Super Contributor
Super Contributor

Re: Reference a column to filter a nested table in Power Query?

Awesome. Thanks. As I was working through it I was thinking if this were in DAX I'd just create a variable or use EARLIER() to get what I wanted. Didn't occur to me to use a variable in Power Query. I wouldn't have gotton the "each" statements right anyway...

 

Many thanks! Very elegant. 

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)