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

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

Reply
gadao
Frequent Visitor

Use Parameter as Query Reference in Source

I have query (query 1) that performs a lot of steps to correct the dataset, I load it to excel and then I loaded it back to PQ, Now I use this query (query_1) to perform other corrections, which give me some performance while I do the subsequent query steps.

 

But in the future I will change to query 1 and discard query_1...

 

The thing is, I would like to use a Parameter to rapidily change the reference.

Without using a parameter:

let

Source = #"query 1"

in

Source

 

I want to use the parameter value in the blue highlighted text.

 

 

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @gadao 

You can try the following solution:

1. create a custom fuction SwitchQuery:

(query as table)=>
let 
source = query
in source

2. Invoked fuction:

let
    Source = SwitchQuery(Query2)
in
    Source

 2. for the Main table:

let
    Source = #"Invoked Function"
in
    Source

You only need to change the query of the invoked function to change the query of the main table at any time.

 Result:

vangzhengmsft_0-1648532491847.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @gadao 

You can try the following solution:

1. create a custom fuction SwitchQuery:

(query as table)=>
let 
source = query
in source

2. Invoked fuction:

let
    Source = SwitchQuery(Query2)
in
    Source

 2. for the Main table:

let
    Source = #"Invoked Function"
in
    Source

You only need to change the query of the invoked function to change the query of the main table at any time.

 Result:

vangzhengmsft_0-1648532491847.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

ilton
Helper I
Helper I

Hi @gadao 

Are you trying to use a variable to select wich query is going to be executed?

If so, you can use a function that reads the parameter and selects the quey.

 

If this helps onsider marking it as a solution

 

gadao
Frequent Visitor

I think isn't that...

 

Let me put this way, let's say I have two queries in PQE and then i created a blank query.

 

If I write: let Source = #"Query1" in Source | it will show the data from Query1 if I change the code for Query2 it will show the data in Query 2,

 

I want a switcher to make this change using a parameter or any other thing.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Kudoed Authors