The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I need help with the following issue:
I have two tables where the following columns exist:
TableA
Category | Product |
A | Cars |
B | Planes |
C | Trains |
D | Bicycles |
TableB
Products | Color |
Cars | Blue |
Cars | Green |
Cars | |
Planes | Blue |
Planes | White |
Planes | |
Trains | Blue |
Trains | Black |
Trains |
I need to create a new table that contains three columns from the two tables, where all the values of all the columns are kept, i.e.:
Category | Products | Color |
A | Cars | Blue |
A | Cars | Green |
A | Cars | |
B | Planes | Blue |
B | Planes | White |
B | Planes | |
C | Trains | Blue |
C | Trains | Black |
C | Trains | |
D | Bicycles |
Any help in achieving this is much appreciated.
Thanks!
Solved! Go to Solution.
@Chris2016
First create a relationship between table A and table b using the field products. Then create the following table to have the desired results as a table.
New Table =
SELECTCOLUMNS(
NATURALLEFTOUTERJOIN( TableA , TableB ),
TableA[Category],
TableA[Product],
TableB[Color]
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Chris2016
First create a relationship between table A and table b using the field products. Then create the following table to have the desired results as a table.
New Table =
SELECTCOLUMNS(
NATURALLEFTOUTERJOIN( TableA , TableB ),
TableA[Category],
TableA[Product],
TableB[Color]
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thanks a lot for your help, Fowmy.
I do have a relationship like you mentioned:
While in my test pbix I have an error in the formula, the table is displayed as expected.
However, in my actual report I get this error:
The relationship I have between TableA and TableB is between the IDs of columns Product, but it is a many to many relationship. Is this what's effecting the NATURALLEFTOUTERJOIN function?
Thanks a lot!
@Chris2016
Yes, Many to Many relationships will not work in this case. I am not sure what your are trying to achieve by mergeing these tables. However, please try to keep one to many relationship by having a relevent dimension table.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
User | Count |
---|---|
11 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
14 | |
14 | |
9 | |
7 |