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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Toast36
Helper I
Helper I

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] o

Hi all, I'm trying to filter one table by the results of another table in Power Query but I am getting the very useful error of 

"Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?"

 

Can anyone let me know what I'm doing wrong here please?

 

"let
Source = Sql.Database("sql1.database.windows.net", "db1", [CommandTimeout=#duration(0, 5, 0, 0)]),
InventoryDimension = Source{[Schema="RPT",Item="InventoryDimension"]}[Data],
Custom1 = let
l = Table.SelectRows("Sales",each [Inventory Dimension Key]),
res = Table.SelectRows([Inventory Dimension Key],each List.Contains(l,[Inventory Dimension Key]))
in
res
in
Custom1"

1 ACCEPTED SOLUTION
v-karpurapud
Community Support
Community Support

Hi @Toast36 

Thank you for reaching out to the Microsoft Community Forum.
 
A special thanks to @dufoq3 for responding on this topic.

It looks like the issue arises from a cyclic reference when filtering the InventoryDimension table using the Sales table.

Try buffering the Sales table before using it for filtering: 

let

    Source = Sql.Database("sql1.database.windows.net", "db1", [CommandTimeout=#duration(0, 5, 0, 0)]),

    Sales = Table.Buffer(Source{[Schema="RPT", Item="Sales"]}[Data]),

    InventoryDimension = Source{[Schema="RPT", Item="InventoryDimension"]}[Data],

    SalesKeys = List.Distinct(Sales[Inventory Dimension Key]),

    FilteredInventory = Table.SelectRows(InventoryDimension, each List.Contains(SalesKeys, [Inventory Dimension Key]))

   

in

    FilteredInventory

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.


Thank You

View solution in original post

8 REPLIES 8
v-karpurapud
Community Support
Community Support

Hi @Toast36 

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Toast36 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Toast36 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Toast36 

Thank you for reaching out to the Microsoft Community Forum.
 
A special thanks to @dufoq3 for responding on this topic.

It looks like the issue arises from a cyclic reference when filtering the InventoryDimension table using the Sales table.

Try buffering the Sales table before using it for filtering: 

let

    Source = Sql.Database("sql1.database.windows.net", "db1", [CommandTimeout=#duration(0, 5, 0, 0)]),

    Sales = Table.Buffer(Source{[Schema="RPT", Item="Sales"]}[Data]),

    InventoryDimension = Source{[Schema="RPT", Item="InventoryDimension"]}[Data],

    SalesKeys = List.Distinct(Sales[Inventory Dimension Key]),

    FilteredInventory = Table.SelectRows(InventoryDimension, each List.Contains(SalesKeys, [Inventory Dimension Key]))

   

in

    FilteredInventory

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.


Thank You

dufoq3
Super User
Super User

Hi @Toast36,

 

check this:

dufoq3_0-1742920088241.png

let
    Source = Sql.Database("sql1.database.windows.net", "db1", [CommandTimeout=#duration(0, 5, 0, 0)]),
    InventoryDimension = Source{[Schema="RPT",Item="InventoryDimension"]}[Data],
    Custom1 =
        let
            l = TableName[ColumnName], //i.e. Sales[Inventory Dimension Key] column which you want to filter by
            res = Table.SelectRows(TableName,each List.Contains(l, [Inventory Dimension Key])) //TableName you want to filter
        in
            res
in
        Custom1


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

That seems to have worked from a code perspective, thanks, but has introduced another error

A cyclic reference was encountered during evaluation.

So, you should provide samle data with full description of your issue. Don't forget to provide also expected result.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

This is the code that is being used

Toast36_0-1742924721610.png


Parallel running is disabled so the 500 Sales Table should run first. I want the 600 Inventory table to only show inventory items where there is a corresponding sale record as we have 11million inventory items which are not all relevant to the sales invoices

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.