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
abhishek_ap4
Regular Visitor

parameterized direct query in powerBI

Hi All,

 

I'm trying to run a direct query with a parameter, (parameter value is selected based on user selection in slicer and capturing it in the parameter) below is the Mquery, The query works fine in PowerBI Desktop but when published into pPowerBI service get an error (unable to connect to DB/timeout error/contact DB adminstration) , their are other direct queries in file without where clause (slect * from table) this query is able to connect to DB only Query with where clause or parameter value is not able to connect on publishing into PowerBI service, any help would be ge greatly appriciated. 

 

In below scenario I'm calling a function public.tna_get_po_milestone_date by parameter passing value (styleID) alomng with other hardcoded values.

 

let

//Create the query
dbQuery = "SELECT public.tna_get_po_milestone_date('" & styleID & "','ISD','31-dec-2022','FGA')",
//Get the data
Source = PostgreSQL.Database(<<Server Address>>, <<DB Name>>,[CommandTimeout=#duration(0, 1, 30, 0)]),

Test = Value.NativeQuery(Source,dbQuery, null, [EnableFolding=false])
in
Test

6 REPLIES 6
abhishek_ap4
Regular Visitor

Hi @lbendlin ,

 

In databases supported by PowerBI Direct query its mentioned PostgreSQL is support, direct query with parameters for PostgreSQL works fine in my PowerBI desktop version, but issues is when publised to PowerBI serverice.

DB supported by PowerBI Direct Query : https://docs.microsoft.com/en-us/power-bi/connect-data/power-bi-data-sources

But you are looking for parameterized direct query, right?

actually we choose this direct query option becasue we were not able to plot calculated date field in a any visuals( mentioned issue in this link : https://community.powerbi.com/t5/Desktop/Data-visualization/m-p/2370040)  , so we thought we get the calculation done at back end through direct query. any idea if we can plot caculated measure in any visuals ?

 

 

yes

basically paramterized direct query currently not working in PowerBI Service, the same report with another table without parameter query working fineDirectquery.png

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.