Forum Discussion
Automatically Establish the Relationship between Tables
Hi Manasa55,
Thank you for reaching out to the Microsoft fabric community forum. Thankyou danextian, for his inputs on this thread.
After reviewing the details you provided, I have identified few workarounds that may help resolve the issue. Please follow these steps:
Creating relationships between tables using a Python script, while Power BI supports Python integration for data transformation within Power Query (via the "Run Python script" option), it does not allow defining data model relationships using Python. These relationships must be established manually in the model view or automatically during data load, depending on your settings. If you're looking to automate relationship creation, here are a few options.
Power BI Desktop: Automatic relationship detection relies on heuristics such as column names, data types, and sometimes data values, which may not always be reliable. You can manually create relationships in the Model view for more control.
Power BI XMLA Endpoint: For a Power BI dataset in a premium workspace, you could use Tabular Editor or scripting via XMLA/TOM (Tabular Object Model) to define relationships programmatically, though this requires tools like C# or PowerShell, not Python. In summary, Python scripting within Power BI is effective for data preparation, but not for data model editing, including relationship creation.
Refer to the below link:
Create and manage relationships in Power BI Desktop - Power BI | Microsoft Learn
Run Python scripts in Power BI Desktop - Power BI | Microsoft Learn
Use Python in Power BI Power Query Editor - Power BI | Microsoft Learn
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- v-kpoloju-msft1 year ago
Community Support
Hi Manasa55,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- v-kpoloju-msft1 year ago
Community Support
Hi Manasa55,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.- v-kpoloju-msft1 year ago
Community Support
Hi Manasa55,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.