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
ludovicLaurent
Frequent Visitor

Need help about a powerbi using Native query and connection created dynamically

Hi 

   i have a problem with a powerbi files that i have received. 
   On my computer  with desktop , i can refresh the powerbi files  but if i publish it on powerbi service : i have an issue : i can't parameter the connection through the gateway i have this message 

Unable to determine the data source. When custom connectors are used, the error can happen if gateway doesn't have the extension enabled. Details: Static analysis failed in gateway. gatewayObjectId:<eupi>46929522-e280-4b75-b94b-c30b689a8b68</eupi>, resultCode:FailedWithUnknownOrUnsupportedDataSources Query contains unsupported function. Function name: AmazonAthena.Databases .

  • Data source for Query1

 

table created in powerquery  used nativequery function  and the connection is created dynamically with different parameters 

this is an example of powerquery script from a table 


let
// Define parameters here for   
p_dsn = Text.From(#"ODBC Name - (1)"),
p_environment = Text.From(#"Environment - (1)"),
p_customerNumber = Text.From(#"Customer Number - (1)"),
p_trimOption = Text.From(#"Columns to Include In WarehouseParts - (1)"),
p_populateScenarioOption = #"Populate This Data Model - (1)",
p_sourceTableName = "vvwarehouseparts",
p_keyFields = "wwarehousepartsdataid, annualsalesunits",
p_extendedFields = "wwarehousepartsdataid, warehousecode, warehousedescription",
p_allFields = "*",
p_manualFieldList = #"Column Override In WarehouseParts - (1)",
p_populateData = #"Populate This Data Model - (1)" and #"Populate Warehouse Part Level - (1)",

//******THE REST OF THE QUERY IS STANDARD AND SHOULDN'T BE ALTERED******

// Build the database and schema name dynamically
p_databaseName = p_dsn,
p_schemaName = p_environment & "_c" & p_customerNumber,

// Define the time_bucket_function (for PeriodID and unique_key)
time_bucket_function = if #"Reporting Time Bucket - (1)" = "Weekly" then "week" else "month",

// Conditional check to either proceed with merge and expand or return an empty table
PreUniqueTable = if p_populateData then
let
// Load the table containing wimportdateID
t_ImportDateIDFilter= #"DATE Static Primary Import Date - (1)",

// Convert the wimportdateID column to a list
l_importDateIDList = t_ImportDateIDFilter[wimportdateid],

// Convert the list to a comma-separated string
p_commaSeparatedIDs = Text.Combine(List.Transform(l_importDateIDList, each Text.From(_)), ", "),

// Modify FieldsToInclude based on conditions
p_fieldsToInclude = if p_manualFieldList = "None" then
if p_trimOption = "ALL FIELDS" then p_allFields
else if p_trimOption = "KEY FIELDS ONLY" then
p_keyFields
else
p_extendedFields
else
p_manualFieldList,

// Construct the SQL query with dynamic schema name
sqlQuery = "SELECT wwarehousepartid as warehousepartid,
CAST(year(DATE(substring(importdatetime, 1, 10))) AS VARCHAR) || '-' ||
LPAD(CAST("& time_bucket_function &"(DATE(substring(importdatetime, 1, 10))) AS VARCHAR), 2, '0') AS PeriodID, "
& p_fieldsToInclude & " " &
"FROM " & p_schemaName & "." & p_sourceTableName & " " &
"WHERE wimportdateid IN (" & p_commaSeparatedIDs & ")",

// Execute the native query
NativeQueryTable = Value.NativeQuery(
AmazonAthena.Databases(p_databaseName, null, []){[Kind="Database"]}[Data],
sqlQuery,
null,
[EnableFolding=true]
)
in
NativeQueryTable
else
#table({"warehousepartid", "PeriodID"}, {}),

FinalTable = Table.Distinct(PreUniqueTable, {"warehousepartid"}) //warehousepartid
in
FinalTable





In the powerbi file , in the data source setting windows  :  no connection appears in "data sources in current files"



Have some idea to solve my issue with powerbi service ?

Thanks

 

 

1 REPLY 1
Anonymous
Not applicable

Hi @ludovicLaurent ,

 

Based on the error message you provided, 'When custom connectors are used, the error can happen if the gateway doesn't have the extension enabled,' if you are using a custom connector, the issue may be due to 'a mismatch of the .pqx file used in the Custom Connectors folder and the current build of the CData Power BI Connector in use.' Please refer to this link for assistance:

Error message: Unable to determine the data source

 

Best Regards,
Bof

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.