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.
From different data sources I have information about parent-child relationships in a dataset. Since the information only includes these entities (and not the complete dataset) I get issues, which can be seen in the spreadsheet.
In order to build the parent-child hierarchy it is apparently a prerequisite, that all parents exist in the child column, even though they don't have parents.
I have tried to:
a) Append queries from source1, source2. This gives an error, that all parents must be in the child column
b) Append queries from source1, source2 and CompleteList, giving all values from CompleteList the value null in parents. This removes the error from a), but results in another error since there is now ambiguity about the parents of the parents, that actually do have parents.
The actual dataset is XML based and contains completely different information, but I thought I'd provide a simplified example below and attached.
Solved! Go to Solution.
Hi Nikolaj,
you can use this query:
let ListOfAllChildren = List.Distinct(List.Combine({Source1[Child], Source2[Child]})), ListOfAll = List.Distinct(CompleteList[Name]), OnlyParents = List.Difference(ListOfAll, ListOfAllChildren), TblAppend = Table.FromList(OnlyParents, null, {"Child"}), Append = Table.Combine({Source1, Source2, TblAppend}) in Append
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
Is that the List from Source 3 only has the Names??
You have mentioned that Append from Source 1 and 2 throwing a error. That doesn't seem accurate. It is just appending the data fro two different sources.
I would like you to post more detailed explaination of the problem.
Hi Bhavesh
a) Yes, the list from Source 3 has in the example only names. The two other columns I have only added in Excel to demonstrate the issue at hand.
b) It is correct, that the append of Source 1 and Source 2 works fine. It is once the PATH function in DAX is used, that it complains about missing children. If you open the PowerPivot of the workbook you will get the error.
Kind regards
Nikolaj
Hi Nikolaj,
you can use this query:
let ListOfAllChildren = List.Distinct(List.Combine({Source1[Child], Source2[Child]})), ListOfAll = List.Distinct(CompleteList[Name]), OnlyParents = List.Difference(ListOfAll, ListOfAllChildren), TblAppend = Table.FromList(OnlyParents, null, {"Child"}), Append = Table.Combine({Source1, Source2, TblAppend}) in Append
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
Hi Imke
Thanks for the reply. Apologies for not getting back, but I did not receive the notification about your post and I thought no-one had answered.
Your solution worked very well. It seems so simple once you have seen it. Thanks a lot!
Nikolaj
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |