Forum Discussion

Rickmaurinus's avatar
Rickmaurinus
Helper V
8 years ago
Solved

Refer to current Query Name in formula

Hi,   I have a set of queries that get historic data from a file.  Next to that I have a set of queries that get data from the web.    The queries from historic data are called  "xxx-xxx1"  & "x...
  • OwenAuger's avatar
    8 years ago

    Hi,

    To my knowledge, a query can't refer to its own name directly.

     

    But I think you can achieve what you're trying to do using the Expression.Evaluate function, as long as you have a way of coming up with a list/table containing the table names as text values.

     

    Here's an idea which could be a starting point.

     

    If you store the names of two tables to be appended in Table1Name and Table2Name, then this expression will append those two tables:

     

    Expression.Evaluate( Table1Name, #shared ) & Expression.Evaluate ( Table2Name, #shared )

     

    or alternatively

     

    Expression.Evaluate( Table1Name & " & " & Table2Name, #shared )

     

    You could have a table with rows containing the pairs of table names, and use Expression.Evaluate within a custom column.

     

    Anyway, that may be useful in some way.

     

    Regards,

    Owen

  • Rickmaurinus's avatar
    3 years ago

    You can use #sections in Power Query to find the list of table names, and refer to it dynamically. Solved! 

     

    --------------------------------------------------

    @ me in replies or I'll lose your thread

     

    Master Power Query M? -> https://powerquery.how

    Read in-depth articles? -> BI Gorilla

    Youtube Channel: BI Gorilla

     

    If this post helps, then please consider accepting it as the solution to help other members find it more quickly.