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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
kevinht
New Member

Datasource Selection based on PBIX refresh location

Hi,

I'm developing a pbix outside of its use environment and I have no permissions to connect to the datasource under my user. So I'm having to email the report to a user with credentials to hit refresh to obtain new data and then they would email it back. This makes it a pain for testing when the data I need isn't there or requires curating.

 

Is there anyway for a PQ Query to attempt to use one datasource and if credentials aren't available it'll failover to another?

 

I've tried the following pattern but PQ still requires I provide valid credentials before I can refresh.

try
    let
        Source = Databricks.Catalogs(...)
    in
        Source

Otherwise 
    let
        Source = Excel.Workbook(...)
    in
        Source

 

1 ACCEPTED SOLUTION
v-venuppu
Community Support
Community Support

Hi @kevinht ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @Omid_Motamedise @PwerQueryKees for the prompt response.

You are on the right track with try...otherwise, but unfortunately Power Query still tries to validate all data sources at refresh time - even inside a try block  - so it will still prompt for Databricks credentials even if it ends up using the Excel fallback.

As a Workaround:

Use a parameter to switch between sources manually:

1.Create a text parameter (e.g., Environment) with values like "Prod" or "Dev".

2.Use conditional logic based on that parameter:

let
Source = if Environment = "Prod" then
Databricks.Catalogs(...)
else
Excel.Workbook(File.Contents("C:\path\to\your\local.xlsx"))
in
Source

 

This way, Power Query only tries to validate the data source that’s actually used - avoiding credential errors for the unused one.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

Thank you.

 

 

View solution in original post

4 REPLIES 4
v-venuppu
Community Support
Community Support

Hi @kevinht ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @Omid_Motamedise @PwerQueryKees for the prompt response.

You are on the right track with try...otherwise, but unfortunately Power Query still tries to validate all data sources at refresh time - even inside a try block  - so it will still prompt for Databricks credentials even if it ends up using the Excel fallback.

As a Workaround:

Use a parameter to switch between sources manually:

1.Create a text parameter (e.g., Environment) with values like "Prod" or "Dev".

2.Use conditional logic based on that parameter:

let
Source = if Environment = "Prod" then
Databricks.Catalogs(...)
else
Excel.Workbook(File.Contents("C:\path\to\your\local.xlsx"))
in
Source

 

This way, Power Query only tries to validate the data source that’s actually used - avoiding credential errors for the unused one.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

Thank you.

 

 

Thanks!  No idea why I never thought of using the basic control structures. But the extra insight about what gets validate at refresh time is great to add to my understanding.

Omid_Motamedise
Super User
Super User

try the following one

    let
        Source1 = Databricks.Catalogs(...),
        Source2 = Excel.Workbook(...), 
        
        Source= if Value.HasError(Source1) then Source2 else Source1
    in
        Source
If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
PwerQueryKees
Super User
Super User

Not sure if this will work, but you could try something like this:

let
    Source = try 
                 Databricks.Catalogs(...) 
             Otherwise 
                 Excel.Workbook(...)
in
    Source

 

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.

Top Solution Authors