Forum Discussion
Build Table/Query Reference Using Other Query Steps as "Variables"
- 2 years ago
Hi
Maybe with Expression.Evaluate
let
Variable1 = "QueryB Part1"
Variable2 = "QueryB Part2"
QueryReference = Expression.Evaluate("#""" & Variable1 & " - " & Variable2 & """", #shared)
in
QueryReferenceStéphane
- 2 years ago
FOLLOW UP - LIMITED USE SOLUTION:
While this solution works in Power Query Editor, it does not work when loading changes into the actual Model (i.e. after pressing "Close & Apply"). For some reason, a blank table is returned.
I narrowed down the issue to using the "#shared" method of referencing a query. Apparently it doesn't work outside the preview/Editor environment. To test this idea, I actually performed the same steps as the = Expression.Evaluate( ..., #shared ) solution provided by slorin (which, again, works in preview/Editor), except manually.
- Created a step Source = #shared. This pulls up the list of queries and library of functions as expected.
- Clicked on "Table" next to the table I wanted to open.
As expected, in preview/Editor, the table came up as expected. But again, like with the Evaluate.Expression() function, when this query loaded into my Model, it returned a blank table.
Unfortunately, this means what I was trying to accomplish originally is still unsolved.
FOLLOW UP - LIMITED USE SOLUTION:
While this solution works in Power Query Editor, it does not work when loading changes into the actual Model (i.e. after pressing "Close & Apply"). For some reason, a blank table is returned.
I narrowed down the issue to using the "#shared" method of referencing a query. Apparently it doesn't work outside the preview/Editor environment. To test this idea, I actually performed the same steps as the = Expression.Evaluate( ..., #shared ) solution provided by slorin (which, again, works in preview/Editor), except manually.
- Created a step Source = #shared. This pulls up the list of queries and library of functions as expected.
- Clicked on "Table" next to the table I wanted to open.
As expected, in preview/Editor, the table came up as expected. But again, like with the Evaluate.Expression() function, when this query loaded into my Model, it returned a blank table.
Unfortunately, this means what I was trying to accomplish originally is still unsolved.