Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have a Table of Accounts which has an Account ID and Parent ID. I want to ADD a new Column in the Query Editor for the Parent Name.
What code should i use to add the new Parent Name field based on image below? I have the ID's for both Parent and Acccount (Child). The Account ID will indicate what the Parent's name will be.
Solved! Go to Solution.
You can simply use your current table as a lookuptable and use the Parent ID. Your formula would look like so:
Table.NestedJoin(#"Removed Other Columns",{"ParentAccountID"},#"Removed Other Columns",{"AccountID"},"Source",JoinKind.LeftOuter)
See this little screencast how it works: https://www.youtube.com/watch?v=looCm3cbINw
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
You can simply use your current table as a lookuptable and use the Parent ID. Your formula would look like so:
Table.NestedJoin(#"Removed Other Columns",{"ParentAccountID"},#"Removed Other Columns",{"AccountID"},"Source",JoinKind.LeftOuter)
See this little screencast how it works: https://www.youtube.com/watch?v=looCm3cbINw
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
thanks again, the trick to change back to source is truly amazing with M....thanks for help again and the video made it easy!
Here is the final code, i changed the source to my Table Select Columns so i didnt have to reselect the columnns to display
let Source = Accounts, TableSelect = Table.SelectColumns(Source,{"AccountID", "ParentAccountID", "Account Name", "AccountTypeID", "AccountLevel", "IsTotal"}), FitlerTable = Table.SelectRows(TableSelect, each ([AccountTypeID] = "H")), #"Merged Queries" = Table.NestedJoin(TableSelect,{"ParentAccountID"},FitlerTable,{"AccountID"},"FitlerTable",JoinKind.LeftOuter), #"Expanded FitlerTable" = Table.ExpandTableColumn(#"Merged Queries", "FitlerTable", {"Account Name"}, {"FitlerTable.Account Name"}) in #"Expanded FitlerTable"
Hopefully, others will find this useful to group accounts together.