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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Pass Credentials to a function to query datasources

Hi everyone, 

 

I'm facing a problem with a Power Query custom function I've written in Power Query to execute the same query on different databases that are configured using a separate Excel File. 

 

The function I use is the following : 

Basically it iterates through an Excel File to get Server and DB and execute a Query.

 

//First we declare our function GetData
let
GetData=(index as number)=>
//Then we will load again the config Excel File inside the function.
//This part may be optimized to not reload each time the data source
let
Datasource=
let
Source = Excel.Workbook(File.Contents(ExcelFile), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true])
in
#"Promoted Headers",
//Get the Data Source of the row n°Index
SERVER=Datasource{index}[SERVER],
DB=Datasource{index}[DB],
//Run our Query to the designated data source
Source = Sql.Database(SERVER, DB,
[Query=FunctionQuery])
in
Source
in
GetData

 

When publishing this report with the aggregated queries on Power BI Report Server, the Scheduled Refresh fails  with the following error message : 

Data refresh failed. Please try again later or contact your administrator.

[0] -1055784934: Credentials are required to connect to the SQL source. (Source at XXXXXX,XXXXX.). The exception was raised by the IDataReader interface

 

Is there any way to pass credentials in Power BI Report Server that are used to identify to the Excel (only Source in Power BI) to the subsequent data sources? 

 

Thank you for your help ! 

Romain

 

 

 

 

 
1 REPLY 1
edhans
Community Champion
Community Champion

for SQL Server, not that I am aware of. The credientials are not stored in M code or passed by M code. It is in a separate blob in the PBIX file, most likely salted, hashed, and double-encrypted.



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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.