This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I'm connecting Power BI Desktop to an OLAP database (Clickhouse) using Direct Query.
I have a typical case to show data from facts table filtering by dimensions table.
I've been able to create a relation between tables, and filter, but resulting SQL generated is correct, but using INNER JOIN, which has poor performance when comparing to use a simple WHERE IN. More info below.
Example tables and data:
facts_table
| dev_id | number_value | datetime |
| 1 | 4 | 2022-06-15T12:57:14 |
| 1 | 5 | 2022-06-15T12:57:14 |
| 2 | 8 | 2022-06-15T12:57:14 |
| 2 | 9 | 2022-06-15T12:57:14 |
dimensions_table
| id | type |
| 1 | mytype1 |
| 2 | mytype1 |
| 3 | mytype2 |
| 4 | mytype3 |
I want to:
In Power BI:
The resulting SQL query being generated is correct, but using INNER JOIN, which has poor performance (almost an hour) when comparing to use a simple WHERE IN. Example of WHERE IN that returns results in seconds:
WHERE dev_id IN (
SELECT DISTINCT id
FROM dimensions_table
WHERE type = 'filter_value'
)
Any idea how I can have an SQL with WHERE IN instead of INNER JOIN? (without having to develop an entire data source + driver to replace query patterns)
Since I don't need to show values from dimensions table, I really don't need an INNER JOIN, I just need to filter based on values on the other table as the SQL extract above.
I also tried:
Notes:
Thanks in advance.
@amitchandak , thank you for your hints.
I tried your last code and it is avoding the inner join, but it is doing in a 2 step SQL query (first get the list of ids and then used in where clause). This causes the second SQL query to be too large (due to list of ids) and exceed the maximum query size of the ODBC driver.
I wolder if there is a way to instruct DAX to do all in one query, resulting in something like (simplified example):
SELECT sum(value_number), ...
FROM facts_table
WHERE dev_id IN (
SELECT DISTINCT id
FROM dimensions_table
WHERE type = 'filter_value'
)
...
Avoiding multi step queries and also avoiding joins.
@cpcostaneves , if you simply join two tables and select some values in dimension table using slicer then it will filter ant measure of fact
Sum(facts_table[Value Number])
Now if you want to add a manual filter, tables are joined
calculate(Sum(facts_table[Value Number]), filter(dimensions_table, dimensions_table[Type] in {"ABC", "DEF"} ) )
you can have in like
measure =
var _tab = summarize(filter(dimensions_table, dimensions_table[Type] in {"ABC", "DEF"} ), dimensions_table[ID])
return
calculate(Sum(facts_table[Value Number]), filter(facts_table, facts_table[ID] in _tab) )
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 38 | |
| 29 | |
| 28 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 66 | |
| 34 | |
| 32 | |
| 25 | |
| 23 |