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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nima_mlk
Frequent Visitor

We couldn't fold the expression to the data source. PostgreSQL DirectQuery

I have set up a DirectQuery connection with a PostgreSQL database hosted on AWS. I'm able to navigate through the tables and views of my database, and also build basic transformations and measures in Power BI Desktop. I can build some visualizations on top of it as well, however some of the columns cause the following error when used in visualizations:

 

OLE DB or ODBC error: [Expression.Error] We couldn't fold the expression to the data source. Please try a simpler expression..

 

I tried to isolate the issue and understand the cause. In particular, any Count Distinct aggregation in the "value" fields of visualiztions causes the above error. Even when I create a new measure with COUNTDISTINCT, the same problem presists. Curiously, a new measure with COUNTDISTINCTNOBLANK works fine, but I don't have any null or blank values in the column that I'm counting.

 

Is this a bug? Is there a workaround?

 

PS1: I do NOT have a custom SQL query on the connector

PS2: Even actually complicated queries work well, e.d Percentage of Grant Total Averages, grouped by categories.

PS3: This might be related to this issue, but that one is related to the Amazon Redshift data source.

 

Power BI Desktop Version: 2.73.5586.561 64-bit (September 2019)

Npgsql-4.0.9

3 REPLIES 3
ShaWo
Advocate I
Advocate I

I'm experiencing the same issue with AWS RDS hosted PostgreSQL. Some tables work fine and some complicated measures do go through quite easily, but on some tables or views there seem to be a problem. Some basic queries like querying the store names from a table with 17k records cause an error. That shouldn't be an issue. When I run a similar query in the db theres no errors. Theres only 4 distinct values in that column and if I do a count or distinct count of those values then it works. All the summarizable fields in the that table work fine but text columns don't. On a different table some of the text columns work and some don't.

I actually continued the tests and one weird thing came up. One of the connected tables that I have the problem with is a view in the database. There's a store name and product name fields in the view that aren't working and giving me the aformentioned error message. I took the ddl from that view and created a new query to the database with that views exact SQL statement and surprise surprise those two fields don't give any errors.

What on earth is going on?

v-chuncz-msft
Community Support
Community Support

@nima_mlk 

 

To get faster and better technical support for this issue, you may directly 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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.