cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ffitzpatrick47
Helper II
Helper II

parameterized queries, query folding and postgre

I have a postgre database (which is cheaper than mssql server) and want to make a parameterized query.  Here's my code:

let
parameters = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
pr = Table.TransformColumnTypes(parameters,{{"key", type text}, {"value", type datetime}}),
prs = Table.SelectRows(pr, each ([key] = "Begin date")),
end_date = prs{0}[value],
string = "select * from h_ar_stage gangster = '"& Text.From(end_date) &"'",
Source = PostgreSQL.Database("localhost", "kobe_bryant", [Query="select * from h_ar_stage"])
in
Source

 

I have to munge around with the date format for the code to actually work, but before I do that, does anyone know the story behind this?

http://community.powerbi.com/t5/Issues/Bug-Query-folding-not-working-with-non-SQL-datasource/idi-p/2...

 

When they say non sql, does that mean non sql server, or non ansi sql based queries.  Knowing msft, I think its likely they weren't smart enough to implement their folding code off of odbc logic and are forming the sql code natively.

 

Also, this is so epically kludgey, is there a more official way to handle parameters in power query?  In the normal data tab, they have msft query, which could be nice, and there are posts from just a couple of years ago where using ?'s work if its in the predicate, though in ssdt, I think the ?'s work everywhere.  Hard to say what' the current best practice.  It changes every year, presumable to keep people in employment.

1 ACCEPTED SOLUTION

@Ffitzpatrick47,

 

I didn't see any other way. You may create a support ticket.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Ffitzpatrick47,

 

You could also take a look at Text.Format function.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, I'm sure I can format the date to a postgre date string. My real question was on query folding and a more official parameter push down method. Do you know?

@Ffitzpatrick47,

 

I didn't see any other way. You may create a support ticket.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors