Forum Discussion

Zabeer's avatar
Zabeer
Helper I
4 years ago
Solved

Add custom column based on column id and field value

Hello, 
I have a requirement to add a column that takes values from a field in another column.
Example-

 


In other words, the new column should take the FieldValue of 'Vendor'  for each unique RowID.
I would need this in Power Query. Kindly help.

Thanks.

  • Zabeer 

    You can add custom column in PQ as follows: Replace "Previous Step" with your last step in the query

    (x)=> Table.SelectRows(#"Previous Step", (y)=> y[ColumnID]  = x[ColumnID] and y[Field]  = "Vendor"  )[FieldValue]{0}

      

     

3 Replies

  • Zabeer 

    You can add custom column in PQ as follows: Replace "Previous Step" with your last step in the query

    (x)=> Table.SelectRows(#"Previous Step", (y)=> y[ColumnID]  = x[ColumnID] and y[Field]  = "Vendor"  )[FieldValue]{0}

      

     

  • Fowmy : Thanks for your reply. What parameters do I then need to invoke the function?

    • Fowmy's avatar
      Fowmy
      Super User

      Zabeer 

      You can click Column Column, paste the above code, click OK  then remove the word  "each" in the formula   bar