Forum Discussion

asif999's avatar
asif999
Frequent Visitor
3 years ago
Solved

Table.SelectRows Custom Column Looping Variable

I am new to Power Query.   I got this solution from another forum. I want to understand the logic behind this function.       Funtion used = Table.AddColumn(Source, "Custom", each Table.S...
  • AlienSx's avatar
    3 years ago

    Hi, asif999 it's all about misleading "each" replacing (_) => and omitting _ later. Makes sense to use this in simple expressions but when you are dealing with iterator inside another iterator ... it's easy to get lost. Rewrite your step as below. Table.AddColumn iterates Source and (w) is a current row of that iteration. But w[Order ID] is another table you are iterating. (x) is a current item (row) of that iteration (over w[Order ID] table)  

     

    Table.AddColumn(Source, "Custom", (w) => Table.SelectRows(Source,(x) => x[Order ID]= w[Order ID]))