Skip to content
Advertisement

Turn these temp tables into one longer subquery (can’t use Temp tables in Power BI)

Currently I have created these temp tables to get the desired output I need. However, Power BI doesn’t allow the use of temp tables so I need to get this all into 1 query using inner selects.

This code is simple and straight forward. However I can’t seem to figure out using a subquery. Here is what I have. It works for the FirstListID select statement, but not the SecondListID portion. I believe this is because you can’t reference the inner most select statement with multiple different outer select statements, but I could be wrong.

Advertisement

Answer

Just to show, for completeness, how you could use CTEs to replace the #temp tables, it would be something along the lines of

Note the use of dateadd which is recommended over the ambiguousdate +/- value assumed to be days, and where relevant meaningful table aliases.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement