cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
ninsights
Helper II
Helper II

Change the SQL Database Name of a Data Source based on User ID

I have 50 distributors (sellers of our products). Each distributor has as [Company ID].

Each distributor has their own database on the same SQL Server. The database structures are the same.

 

What I would like to do is to have Power BI recognize the user and dynamically choose the correct database name for that user.

 

For example, if I have the following:

if [userID] = [Distributor1] ,
   then the data source is [Database1]   (set server name = "mrl" and database name = Database1)

if [userID] = [Distributor2] ,
   then the data source is [Database2]   (set server name = "mrl" and database name = Database2)
...and so on for all 50 distributors.

Is this possible in Power BI?

Thank you for any assistance you can provide.

Tracey.

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You might be able to do this if you used direct query and looked at this post by @GilbertQ - Power Query (M) – Passing Parameters dynamically to a SQL Server Query - Data Analytics | FourMoo an...

But not sure how performance would be, and what things Direct Query will mess up for you - you cannot use Power BI Time Intelligence.

 

What I would be more inclined to do is create a view on the server that combines all relevant fact tables into one, with a new field that indicates the user name, then use RLS to filter the data at the report level.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Glad I could help @ninsights 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

You might be able to do this if you used direct query and looked at this post by @GilbertQ - Power Query (M) – Passing Parameters dynamically to a SQL Server Query - Data Analytics | FourMoo an...

But not sure how performance would be, and what things Direct Query will mess up for you - you cannot use Power BI Time Intelligence.

 

What I would be more inclined to do is create a view on the server that combines all relevant fact tables into one, with a new field that indicates the user name, then use RLS to filter the data at the report level.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thank you @edhans for this information and letting me know that time intelligence won't work under that scenario. That's very important for this dashboard so I will ask IT to create the view you suggested that I can use with RLS. I greatly appreciate your response. 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors