cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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
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 Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (3,018)