Forum Discussion
MC4
6 years agoFrequent Visitor
Custom Column - Value from other query
Hi there, I have added a Custom column to a Quaery (Query 1) in Power Query and I want the value on each row in this column to equal to the value from a single row in another Query (Query 2). ...
- Anonymous6 years agoJust do this:
Table.AddColumn(PrevStep, “NewColumnName”, each OtherTable[ColumnName]{2})
//{2} being the zero-based position of the other table’s item that you want. You could also do
each OtherTable[ColumnName] = “Some Team”, type text).
artemus
6 years agoMicrosoft Employee
Assuming you want to glue the other table vertically you can try this (Add custom step):
= #table(type table Type.ForRecord(Type.RecordFields(Type.TableRow(Value.Type(PreviousStep))) & Type.RecordFields(Type.TableRow(Value.Type(OtherTable))), false), List.Transform(List.Zip({Table.ToRows(PreviousStep), Table.ToRows(OtherTable)}), each _{0} & _{1}))
Replace PreviousStep with the previous step in your query, and OtherTable with your other table.
MC4
6 years agoFrequent Visitor
Thanks artemus - This feels close to what I am trying to do.
I have added your suggested custom step as a formula to my custom column. However, when I do this, the "Club Name" column in Table 2 is populated with "Table" and not the desired "Club 3".
This may be a result of how I have translated the Custom Step you provided.
Here is a link to the file in which perhaps you can see how I have attempted to transalte your custom step
https://www.dropbox.com/s/6qlfvrdw5h8cwz6/Sample%20Power%20BI%20R1.pbix?dl=0
Thanks!