Forum Discussion
DirectQuery error when loading visualization from PostgreSQL table using Dynamic M query parameter
- 2 years ago
Instead of using the Query option directly I recommend you try the Value.NativeQuery variation. That may make it easier to consume the parameter.
The SQL statment (as it's written in Power Query) is correct, because even though the value in the proj column is being called via the Text.From function, it's actually an integer and not a text value. I have to use the Text.From function because the entire SQL query is itself a string, so using the Number.From function results in an error due to the conflicting data types:
Out of curiosity, I tried both of the following lines of code in DBeaver, and they both successfully loaded the table. I assumed that using the single quote around an integer value would result in it being cast as a text datatype and result in an error, but it apparently doesn't:
select * from foo1.test where proj = '12345';
select * from foo1.test where proj = 12345;
I've also confirmed that inserting a single quote before and after the double quote while using the Text.From function will result in the table being loaded just the same as the original SQL query, but leads to the same error in the visualization. So, I'm still left with the same error as before regardless if I use a sinqle quote or not.
Thank you for the response.
- lbendlin2 years agoSuper User
Instead of using the Query option directly I recommend you try the Value.NativeQuery variation. That may make it easier to consume the parameter.