Forum Discussion
Multiple relations between tables: duplicate or reference
- 2 years ago
Hi PWVL_Arno 🙂
I was checking your question and I might not have all the information and requirements for your need.
But one tradicional approach is to unpivot, e.g, 1 row will be converted in has many rows and column ID
I've created example tables that you can use also for testing. Code:
Requests -let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQooyswrSS1SyMsvUSjPL8rOzEsHioJkjMB0rE40mOWcn1tQClKYWaxQnJNfDlego2QMVmQMZLmk5iRWKmTmKRQkViZnpCZng2UhKk2UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Request ID" = _t, Request = _t, ResponsibleUserID = _t, AffectedPersonID = _t, ReportingPersonID = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Request ID", Int64.Type}, {"Request", type text}, {"ResponsibleUserID", Int64.Type}, {"AffectedPersonID", Int64.Type}, {"ReportingPersonID", Int64.Type}}) in #"Changed Type"
PersonsAndUsers-let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOSCzKz1OK1YlWMgJyQ/JzwWxjINsrPwMiYQLk+GYmZySm5ijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PersonAndUsers ID" = _t, PersonAndUsers = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"PersonAndUsers ID", Int64.Type}, {"PersonAndUsers", type text}}) in #"Changed Type"
The way I would deal with that business need would be to select the 3 ID columns and unpivot the them, resulting in:
This means that you can now create an "healthy" relationship between dimensions table and facts table (one to many):
And now you can filter, make calculations... on the request(s) by person
Hope I was of assistance!
Cheers
Joao Marcelino
Ps- Did I answer your question? Mark my post as a solution! Kudos are also appreciated 🙂
Hi PWVL_Arno 🙂
If you think this solution might help other fellow Power BI users, pleasure consider marking it as a solution for better indexation and visibility 🙂
Hope I was of assistance!
Cheers
Joao Marcelino