Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
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) )
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.