Forum Discussion
How to create inner join relationship in data model?
hi Guys,
i have inner joins relationships in postgres and want to reflect/reproduce the same relantionships in power BI.
How to do this in data model?
Best,
Jacek
5 Replies
- Tahreem24Super User
jaryszek You must have some common key columns in both the tables so based on that you can simply join in Relationship tab of PBI desktop. (refer below screen shot)
Go to Relationship tab >> Click on Manage Realtionship >> New >> Then select table name from drop down and select key column (Category column in my case) and similarly select second table and do the same. As per your need select Cardinality and hit OK.
- isabellaMicrosoft Employee
Hi jaryszek
The [ServerClass] fields in these two tables are totally different. How can you create a one-to-one relationship? Did you choose the wrong table?
Best Regards,
Community Support Team _Isabella
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- jaryszekSuper User
Hi, thank you.
The issue is that i can not use any kind of relationship in my case:i have not unique values in both columns.
What is the best practice in this case? Should i create relationships in this case at all?
Or just create new tables merged/joined in Power Query?In SQL i would create INNER JOIN between these tables and ...that's it. I would have proper filter prepared.
Best,
Jacek - jaryszekSuper User
Anyone?
Jacek
- AnonymousNot applicable
Hi jaryszek,
Probably late reply but might help others.
I struggled a while with this and found a solution that worked for me:You need to create a new query and connect the two others through this new one.
1. From your PBI report, click "Transform Data" (ie: open the Power Query Editor)
2. In your query with the ServerClass (as per your example), right click at the top of your ServerClass column, then click "Add as New Query". Only if all of your Server Classes are written in this column, otherwise you will need to merge it with the other column from the other query.
3. In your new query (should be named ServerClass, as per your column), right click at the top of the column and click "Remove Duplicates".4. Click "Close & Apply". In the Model View, the relationship should get created automatically but you might need to edit it to make the "Cross filter direction" = "Both"
For my application, the model view looked like that:
Connecting the "Retrieval IDs" straight away didn't work... But this solution did it.