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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
hpratap
Regular Visitor

clickhouse how to do a complex query

Hello,


I'm facing an issue with Power BI where I need to utilize a complex ClickHouse query. While I can successfully connect to individual tables using the ClickHouse connector (which allows direct connections), my requirement is to execute my own custom query that involves joining multiple tables with specific conditions and subqueries. However, it seems this feature isn't available in the current setup of Power BI's ClickHouse connector.


Could you please advise on how I can achieve this?


Thank you for your support!

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @hpratap ,

 

The current Power BI ClickHouse connector doesn’t support entering custom SQL queries directly like some other database connectors do. It only lets you import tables or views.

Workarounds:

  • Create a View in ClickHouse: Write your complex SQL as a view on the ClickHouse server, then connect to that view from Power BI. This is the most reliable way.

  • Use ODBC Connector: If your setup allows, try connecting via the ClickHouse ODBC driver, Power BI’s ODBC connector lets you paste in custom SQL queries.

  • Dataflow or ETL: As an alternative, you could pre-process your data (with your query logic) upstream and then connect Power BI to the output.

Unfortunately, until Power BI adds native support for custom queries in the ClickHouse connector, these are your best options.

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

2 REPLIES 2
v-sgandrathi
Community Support
Community Support

Hi @hpratap,

 

Thank you for bringing up this question.

@rohit1991  provided the correct answer, thank you for your response to the query.

 

At present, the native Power BI ClickHouse connector does not allow you to enter custom SQL queries directly, unlike some other database connectors. You are restricted to choosing from predefined tables or views.

The workarounds that have been suggested are currently the most effective solutions available.

 

For more advanced needs, you could consider developing a custom Power Query connector using the Power Query SDK, which can provide additional flexibility if you have the technical resources.

 

You can find more information in this Microsoft documentation:

Power Query ClickHouse connector - Power Query | Microsoft Learn

 

I hope this explanation helps clarify your concern. If you have any more questions, please feel free to ask.


rohit1991
Super User
Super User

Hi @hpratap ,

 

The current Power BI ClickHouse connector doesn’t support entering custom SQL queries directly like some other database connectors do. It only lets you import tables or views.

Workarounds:

  • Create a View in ClickHouse: Write your complex SQL as a view on the ClickHouse server, then connect to that view from Power BI. This is the most reliable way.

  • Use ODBC Connector: If your setup allows, try connecting via the ClickHouse ODBC driver, Power BI’s ODBC connector lets you paste in custom SQL queries.

  • Dataflow or ETL: As an alternative, you could pre-process your data (with your query logic) upstream and then connect Power BI to the output.

Unfortunately, until Power BI adds native support for custom queries in the ClickHouse connector, these are your best options.

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors