Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
avbraga
New Member

table names as a quoted string parameter in advanced editor

Hi all,

 

using the Advanced Editor, consider this piece of code below. It's orginial without using a "parameter" to substitute the values Q8agree, "agree":

 

#"Merged Queries" = Table.NestedJoin(#"Filteres Rows", Q8, agree, {"answer"}, "agree", JoinKind.FullOuter)

 

I am going to be creating a number of tables for many survey question and likert tables, and would like to parametrise the above code. Something like:

 

question_par = "Q8", // where this is the question number

likert = agree, // where this is a table 

 

#"Merged Queries" = Table.NestedJoin(#"Filteres Rows", question_par , likert , {"answer"}, "agree", JoinKind.FullOuter)

 

but as you can see, the issue is the quoted agree ("agree"). A very easy fix would be to create another parameter called something like likert_quoted = "agree", replace it and be done with it, but I am wondering if there is a way to create a function that extracts the name of the table agree (assigned in the likert variable) and returns the quoted string "agree".

 

Your help appreciated. Thanks,

 

Alex Braga

2 REPLIES 2
ronrosenfeld
Frequent Visitor

If I misunderstood and you need to extract the table name from the table, you can still use the sections parameter.

ronrsnfld
Super User
Super User

You can make use of #sections.

 

Assume you have a parameter named likerts which contains the text string of the table of interest.

The following function, which you can name whatever you want, will return the relevant table.

 

()=>
let
    #"Queries" = Record.SelectFields(#sections,"Section1")[Section1],
    #"likert name" = #"Queries"[likert],
    #"likert table" = Record.FieldValues(Record.SelectFields(#"Queries",#"likert name")){0}
in
    #"likert table"

 

This function will return an error if the table does not exist.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.