Forum Discussion

intrasight's avatar
intrasight
Icon for Helper IV rankHelper IV
10 years ago
Solved

how to reference named table in a query?

 

 

I am migrating the standard "parameter table function" that uses an Excel workbook to instead use a named table. My table is named "Parameters". My function is:

 

(ParameterName as text) =>
let
ParamRow = Table.SelectRows(Parameters, each ([Name] = ParameterName)),
Value=
if Table.IsEmpty(ParamRow)=true
then null
else Record.Field(ParamRow{0},"Value")
in
Value

 

But this error is reported:

An error occurred in the ‘’ query. Expression error: The name 'Parameters' wasn't recognized. Make sure it's spelled correctly.

 

So clearly I don't understand how to reference named tables in Power Query. What am I missing?

Thanks

  • greggyb's avatar
    greggyb
    10 years ago

    You should be able to make the reference as you're describing. I would double check for case and extraneous whitespace (trailing spaces are never fun). If these check out, would you be able to share a sample .pbix (hosted publicly on OneDrive or similar) that recreates the issue for us to look at, please?

8 Replies

  • MattAllington's avatar
    MattAllington
    Icon for Community Champion rankCommunity Champion

    So this function references an object (table?) called Parameters. Is that loaded in your data model already?  I have never used functions in Power BI. I assume they work - not sure. 

  • It may recognize the query as table in M formula. Try to create another query of the current Parameters table, then name the query to "Parameters".

     

    • intrasight's avatar
      intrasight
      Icon for Helper IV rankHelper IV

      The parameters table is a query. The query name is "Parameters". It is of type "table"

      • greggyb's avatar
        greggyb
        Icon for Resident Rockstar rankResident Rockstar

        You should be able to make the reference as you're describing. I would double check for case and extraneous whitespace (trailing spaces are never fun). If these check out, would you be able to share a sample .pbix (hosted publicly on OneDrive or similar) that recreates the issue for us to look at, please?

  • pqian's avatar
    pqian
    Icon for Microsoft Employee rankMicrosoft Employee

    By "Named Tables" do you mean a table in your Excel workbook? PowerQuery (M language) cannot directly interact with Excel's objects. You need to import the workbook and then operate on the imported Query.

    • intrasight's avatar
      intrasight
      Icon for Helper IV rankHelper IV

      Hi,

      I have a query named "Parameters". It is of type "table" (has table icon in query sidebar). It was created with the new "Enter Data" feature.

      Thanks,

      Chris