Forum Discussion

mm5308's avatar
mm5308
Icon for Helper I rankHelper I
2 years ago
Solved

Build Table/Query Reference Using Other Query Steps as "Variables"

Been searching for an answer for a while and honestly not even sure if I was using the right search terms...   In Power Query, I'm trying to "build" a table/query reference based on previous table ...
  • slorin's avatar
    2 years ago

    Hi

    Maybe with Expression.Evaluate

     

    let
      Variable1 = "QueryB Part1"
      Variable2 = "QueryB Part2"
      QueryReference = Expression.Evaluate("#""" & Variable1 & " - " & Variable2 & """", #shared)
    in
      QueryReference

     Stéphane

  • mm5308's avatar
    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.