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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
SFLPBI
Frequent Visitor

DirectQuery + COMBINEVALUES() + RELATED()

I am relating some tables together using the COMBINEVALUES() function.  It works great.  As soon as I reference one of the values i.e. x = Table1[val1] * RELATED(Table2.[val2]), the SQL generated starts to inner join Table2 2 times.  One joining on the compound key (correctly) and the other using the concatonated values from both tables.

 

Any insight or work around will be greatly appreciated!

 

Thanks

5 REPLIES 5
Anonymous
Not applicable

I'm having the same problem, but I don't think the measure change will work for me, as I'm trying to get attributes across related tables.

 

For example, two tables are related via three columns.  Then a third table is related via a combination of other columns from those two tables.  I use RELATED in the many side of the two tables with COMBINEVALUES, but it does the concatenation thing.  

v-lili6-msft
Community Support
Community Support

hi, @SFLPBI 

Please check this blog if it could help you:

https://www.sqlbi.com/articles/using-combinevalues-to-optimize-directquery-performance/

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-lili6-msft  for taking the time to reply. 

 

Unfortunately that article does not help, as it only shows how to create relationships with COMBINEVALUES().  The initial subquery/join is fine.  When I added the RELATED() function, it adds an additional subquery/join based on the concatonated values instead of the individual components of the COMBINEVALUES() function.  So the resulting query ends up with TWO subqueries; the first joining correctly and the second on the concatonated string.

 

Kind regards,

Kevin

SFLPBI
Frequent Visitor

By the way, the below "DAX pattern" produces the correct SQL joins and runs reasonably fast, but it doesn't return a single result from the SQL server side.  This causes the "1 million row" limit error for my particular application.

 

scaledSum$ =
    var SCALED = SUMMARIZE(Table2, [Date], [key1], [key2], [Scale], "ret$", SUM('Table1'[value$]))
    return SUMX(SCALED, [Scale] * [ret$])
SFLPBI
Frequent Visitor

Another update.  The below code appears to be doing the trick.  I am going to continue to test this out.

 

scaledSum$ = SUMX(Table1, RELATED(Table2[Scale]) * Table1[value$]))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors