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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
mferraricloudsu
Regular Visitor

Dynamic SQL datasource selector

We have this scenario:

  • 1 Azure App Service back-end API service (.NET 7)
  • 1 Azure App Service front-end client App
  • Azure SQL Server elastic pool with hundreds of databases

 

Basically, a user login trough front-end to his own company db. Front-end calls back-end service and start to interact with his own company data.

What we are trying to do is to use Power BI in order to create one or more report templates and embed it inside the front-end. The goal is to have a report which dynamically retrieve data from the proper db in according to user credentials.

Example:

  • user: MrX is logged in to company with id 50 (so all data are retrieved from SQL db MyDatabase_50).
  • once MrX is logged in, have an app section that shows a Power BI report pre-filtered with data taken only from MyDatabase_50

 

Another important aspect: new companies will be continuously activated, so it's important that Power BI report data sources list is dynamically synced with the current companies list.

 

Does exists a way to implement this kind of architecture and which is the best approach to reach this behavior with Power BI ?

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @mferraricloudsu,

It sounds like indireclty getting data requirement. You can store these company and correspond server information to a table and use power bi to getting data form that table.
Then you can simply use M query to getting data from specific row of the table records. (use these field values as connection strings to getting data)

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
mferraricloudsu
Regular Visitor

@Anonymous my problem is not to bind record to users, my goal is to create one single Power BI template and attach dynamically new datasources (each one is a SQL database, one for each company). So, if a new company will be created, Power BI report will recognize automatically that a new datasource is available and can show the data of new company/db.

 
Anonymous
Not applicable

HI @mferraricloudsu,

It sounds like indireclty getting data requirement. You can store these company and correspond server information to a table and use power bi to getting data form that table.
Then you can simply use M query to getting data from specific row of the table records. (use these field values as connection strings to getting data)

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

HI @mferraricloudsu,

I'd like to suggest you binding users with their companies and use company field to link to other fields. Then you can add a RLS filter on the company field based on current username to apply to users.

After above steps and assign role to users, these records will be fileted based on current users’ company.

Solved: RLS with UserName() - Microsoft Fabric Community

Row-level security (RLS) with Power BI - Power BI | Microsoft Learn
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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