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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
paulvans182
Helper III
Helper III

Invoke Function: Reference Query using Query name as parameter

Good morning, 

 

I am busy experimenting with invoking functions in Power BI. I am trying to find a method of Referencing a Query using Invoked Functions.

 

I thought I could use the following:

 

 

= (strQueryName, strFieldName) =>

let
    Source = strQueryName
in
    Source

 

 

the strFieldName is a field in said query... and once I am able to reference said query I can begin using it.

 

However, when I attempted to use this code - it treated the strQueryName as Text - and so the function simply returns the text of the parameter.  Is there a data type I need to set the parameter to correctly reference the query?

 

Thank you for any help that can be provided

 

Kind regards,

Paul

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @paulvans182 

 

Sorry, probably misunderstood the original requirement.

try this

= ( strQueryName as table ) =>
let
    Source = strQueryName 
in  
    Source

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @paulvans182 

 

Sorry, probably misunderstood the original requirement.

try this

= ( strQueryName as table ) =>
let
    Source = strQueryName 
in  
    Source

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

I have a very similar situation, but instead of trying to reference a query/table, I want to reference a Parameter defined in my PowerBI file (not a function parameter).

So I basically have a parameter that
TrainA = "ID OF TRAIN A"
TrainB = "ID OF TRAIN B"

and I would like to be able to tell which of the 2 parameters should my function use. 
like 
myTable = CallMyFunction("TrainA"). Inside my function, I do NOT want the text "TrainA" but rather the ID of train A.

I dont see a parameter type of "parameter" as you proposed with the table type. Any way around this?

Hi @Mariusz , 

 

That is absolutely brilliant.

 

Thank you

 

Kind regards,

 

Paul

Hi @paulvans182 

 

No problem at all.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Mariusz
Community Champion
Community Champion

Hi @paulvans182 

 

Please see the attached file with the example of Invoke custom function.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Hi @Mariusz ,

 

Thank you for the suggestion - however, unless i am misunderstanding, your solution appears to add a new column to the already existing table.

 

What I am looking to do, is to create a new query with the same data as the existing query (essentially a duplicate or reference of the query) that I can then manipulate separately.  So, effectively I would have your original Table query, and a new query that looks identical to Table after I invoke the function using the queries name, "Table" as the parameter.

 

Does that make sense?  Thanks again for any help you can provide 

 

Kind regards,

 

Paul

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors