Forum Discussion
dcherkassky
7 years agoNew Member
PowerBI generates an SQL query that is too deeply nested. How to fix?
In PowerBI Query builder, I create the following query:
let
SV_DATA = Sql.Database("my.ip.add.ress", "SV_DATA", [CreateNavigationProperties=false]),
ImportanceTables = Table.SelectRows(SV_DATA, each Text.EndsWith([Name], "_IMPORTANCE_RATINGS")),
Importances = Table.Combine(Table.TransformRows(ImportanceTables, (ImportanceTable) => ImportanceTable[Data]), {"PROG_ID", "RESPONSE_ID", "COMPOSITE", "PRACTICE_NUMBER", "IMPORTANCE_RATING", "CHANNEL", "BREAKOUT", "SOURCE"} )
in
ImportancesAs you can see, the query looks for all tables that end in _IMPORTANCE_RATINGS and combines them into a single table. (This is necessary because there are thousands of *_IMPORTANCE_RATINGS tables and they are added and dropped over time; I therefore can't hard-code them).
The preview works perfectly.
However when I try to apply the query in my report, I get the following error from SQL Server:
DataSource Error: Microsoft SQL: Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries
However, I don't see any way to simplify my work in PowerBI. It seems that it is PowerBI itself that makes the SQL query too complex.
Suggestions?
Thanks, DC
No RepliesBe the first to reply