Forum Discussion
Datasource Selection based on PBIX refresh location
- 1 year ago
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
SourceThis 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.
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!
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.