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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dkbollig72
New Member

Filter Table Column dynamically using each and passing in a value to filter each row with

I have a table that consists of an ID field and values and a copy of the table as a custom column. In that custom column table I would like to filter each row by passing the id field into the filter to on show the related records in the custom column table. Below is what I am trying to do but it is not doing any filtering. I can hard code an ID and it will filter but I want to pass in the current record ID in order to filter each row's table. 

 

 

= Table.AddColumn(ExtractData, "Custom", each Table.SelectRows(ExtractData, each Text.Contains(Number.ToText([FIPS Record]),Number.ToText([FIPS Record]))))

 

 

Attached is a picture how what I would like to do. 

Screenshot 2022-05-27 214143.jpg

 

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @dkbollig72 ,
that's because you use the syntax sugar each-keywords twice. That creates ambiguity - actually, it would be nice if an error was raised instead.
So to solve the problem, you can use a standard-function declaration for one each like so:

Table.AddColumn(ExtractData, "Custom", each Table.SelectRows(ExtractData, (tableInRow)=> Text.Contains(Number.ToText(tableInRow[FIPS Record]),Number.ToText([FIPS Record]))))

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors