Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Austen229022
Helper I
Helper I

Connecting to SQL Server while keeping relationships active

New to dealing with SQL Databases in Power BI so would love some help

 

Currently I am working with SQL database that I am wanting to import the Live Data into Power BI, which I can do then chose the tables that I am wanitng to add.

 

The issue is that there is a fairly complex data relationship model in the background which I need to set up in SQL.

 

How can I have the live data from SQL come into Power BI while also keeping the relationships from SQL Manager?

 

Do I still need to import all the tables into Power BI and create the relationships between the tables in Power BI as well as having the relationships from the SQL database?

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Austen229022 I would recommend creating a view in the SQL putting the logic there and then using that view in Power BI to pull the data. If tomorrow there is a need to change the logic, you can do it in the view, and no need to touch Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

Correct



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Austen229022 I would recommend creating a view in the SQL putting the logic there and then using that view in Power BI to pull the data. If tomorrow there is a need to change the logic, you can do it in the view, and no need to touch Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for replying

 

So when you go through importing the DB from SQL, you would select the view?

Alef_Ricardo_
Resolver II
Resolver II

Yes, you can import live data from SQL into Power BI while keeping the relationships from SQL Manager. Here are the steps you can follow:

1. Go to the `Home` tab of Power BI and click on `Get Data` drop down and further click on `SQL Server`³.
2. A new SQL Server database window will open. Provide server name and database name³.
3. Select `DirectQuery` as data connectivity mode³.
4. Expand `Advanced Option` and paste your query in `SQL statement`³.

This will allow you to import live data directly from the SQL query into Power BI³.

As for the relationships, it's recommended to create views in your SQL database instead of importing tables directly². This creates an indirection layer that simplifies the change management of the database structure². When you import these views into Power BI, it should maintain the relationships defined in SQL.

However, you might still need to define some relationships within Power BI depending on your specific use case and how you plan to use the data within your reports.

Remember, it's always a good practice to only include the columns that are useful and will be used in the Power BI data model when creating your views². This can help improve performance and usability.

I hope this helps! Let me know if you have any other questions.

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.