Forum Discussion
Custom Column - Value from other query
- 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).
Apologies.
Here is a link to a sample file on Dropbox;
https://www.dropbox.com/s/zahfgwhw0h8t909/Sample%20Power%20BI.pbix?dl=0
In Table 2 there is a Custom Column called "Club Name" which is currently populated with just text ("Club 3").
I would like the value in the "Club Name" column to be linked to Table 1, row 3 via a formula instead.
Hope that clarifies.
Thanks again.
I cannot work on it without the source files. When I go into Power Query it says Clubs.xlsx and Sample Table.xlsx are missing.
Just looking though at the data in the DAX model (and I would not do any merge in DAX), you have no filed to merge on, like a customer number, index, or anything else. You cannot say "column 1, row 3" as Power Query has tables, and tables have no concept of row numbers or addressable cells like Excel spreadsheets do.
You should read this article to understand how a Merge works. You can make it somewhat analogous to how a VLOOKUP works. You want to look up this value in that table, then return in formation from that table. VLOOKUP doesn't understand row numbers either, it just needs a field to scan through and find. That is how a merge works.
- MC46 years agoFrequent Visitor
Thanks edhans again for helping out.
I had a look at the article on Merging, and I have merged queries before, however I wasn't sure how to do it in this instance to achieve the desired result.
Here is a link to the file with no external links to source files so hopefully the Queries remain in tact for you:
https://www.dropbox.com/s/ou2phsdyojbx14s/Sample%20Power%20BI%20R1.pbix?dl=0
Is it possible for you to please show the steps in this file on how the Merge would work to achieve the desired result?
Thanks.
- edhans6 years agoCommunity Champion
See the attached PBIX file here.
I'm not clear on the purpose here. Your table already had the club name so not sure why you wanted to get the club name merged from the other table.
If the goal is to get the club name there in the first place, you need some way to link the two tables. In other words, how should a computer know that Club 3 is what goes in your column? You've given it no other info to make that determination.
If I'm misunderstanding, please let me know. If the merge example is what you needed, please mark this as a solution.
- artemus6 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.