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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Advanced Editor - Add Column from Related Table

Added a column from a related table but found out it is not available in Merge tables dialog (Ex: Column = RELATED('Account'[SubRegion]) ).  Found a suggestion to add the column using the Advanced Editor, but editor flags the single quote in the table name.  Anyone have an example of using RELATED in the advanced editor to add a column?  The needed column is two joins over in the relationship diagram.  Data Source is OpportunityLineItem in SalesForce; so SQL views are less than convenient.

Advanced editor failed attempt:

,SubRegion = Table.AddColumn(RELATED('Account'[SubRegion]))
in

Thanks,

Smitty

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Yes, I was mixing DAX with M.  The end objective is to merge two tables, but Custom columns are not available in a merge.  The big picture is to merge Actuals table with Targets table to visualize the % diffs.  The Actuals table needs to join data between three tables and the required column is two joins over from the first table. 

 

Enter the Advanced Editor of the middle table and add a table.join before the final "in" clause to get two columns (Account Key, SubRegion) from the Account table:

 

#"GetSubRegion" = Table.Join(#"Replaced Value2","Account Record Key",Table.SelectColumns(#"Account", {"Account Key","SubRegion"} ), "Account Key",JoinKind.Inner)
in
    #"GetSubRegion"

 

Enter the Advanced Editor of the first table and add a table.join before the final "in" clause to get two columns (Opportunity Key, SubRegion) from the above table:

 

 #"GetSubRegion2" = Table.Join(#"GetFiscalQuarter","Opportunity LI Key",Table.SelectColumns(#"Opportunity", {"Opportunity Key","SubRegion"} ), "Opportunity Key",JoinKind.Inner)
in
    #"GetSubRegion2"

Now that SubRegion is in the first table the rest of the data can be grouped then merged with the Target table.  Any shortcuts to this effort?

HTH,

Smitty

View solution in original post

4 REPLIES 4
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

As @MarcelBeug has mentioned above, you may mix up DAX (RELATED) and Power Query (Advancd Editor). If you want to use RELATED(DAX) function, you can just use the formula below to add a new calculate column under Modeling tab. Smiley Happy

SubRegion = RELATED ( 'Account'[SubRegion] )

c0.PNG

 

Regards

Anonymous
Not applicable

Yes, I was mixing DAX with M.  The end objective is to merge two tables, but Custom columns are not available in a merge.  The big picture is to merge Actuals table with Targets table to visualize the % diffs.  The Actuals table needs to join data between three tables and the required column is two joins over from the first table. 

 

Enter the Advanced Editor of the middle table and add a table.join before the final "in" clause to get two columns (Account Key, SubRegion) from the Account table:

 

#"GetSubRegion" = Table.Join(#"Replaced Value2","Account Record Key",Table.SelectColumns(#"Account", {"Account Key","SubRegion"} ), "Account Key",JoinKind.Inner)
in
    #"GetSubRegion"

 

Enter the Advanced Editor of the first table and add a table.join before the final "in" clause to get two columns (Opportunity Key, SubRegion) from the above table:

 

 #"GetSubRegion2" = Table.Join(#"GetFiscalQuarter","Opportunity LI Key",Table.SelectColumns(#"Opportunity", {"Opportunity Key","SubRegion"} ), "Opportunity Key",JoinKind.Inner)
in
    #"GetSubRegion2"

Now that SubRegion is in the first table the rest of the data can be grouped then merged with the Target table.  Any shortcuts to this effort?

HTH,

Smitty

I was looking for this feature as well.  
While noticed that DAX and M have their contexts in which each excels, I got used to RELATED functionality and wanted to use it in M's GetData context. 

Good luck. 

MarcelBeug
Community Champion
Community Champion

You seem to mix up DAX (RELATED) and Power Query (Advancd Editor).

 

In order to add a column from another table in Power Query, use "Merge Queries" from the menu-options.

No need to do this via the Advanced Editor.

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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