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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Regular Visitor

Passing user selected values to a query to another query

Hello community,


Newbie here.  Trying to see if we can use PowerBi as our solution within a Fortune 100 company.  I picked one of our more difficult reports to start since I needed a challenge.


Here is what I'm trying to do:

1. Pull Contract Numbers via sql using Oracle/Oracle via ODBC to populate a slicer.

2. The user selects 1 Contract Number via the slicer

3. The selected contract number is sent to the next sql statement, using Oracle/Oracle via ODBC, to pull Payment Numbers related to that specific contract.  Those payment numbers would show up in the next "slicer".

4. The user selects 1 Payment Number via the "slicer".

5. The selected Payment Number is sent to the next very very large sql statement, using Oracle/Oracle via ODBC, to pull detailed payment data related to that specific contract/payment number.  That detailed payment data would show up for the users to view in a report. 


Note: I can't just go out to the Oracle Database and pull hundreds of millions of detailed rows for all contracts and payment numbers and then filter from there.  It would take days to return, which is why I need to figure out which contract, then find the payment numbers associated to that contract so the user can select 1 payment number, and then pass the 1 payment number to the very large sql statement (~1800 line sql statement) so that we only get the payment details for that 1 payment number.


I hoping this is possible and how to do it. I looked for 3 days at the "go to this link for using parameters" and "go to this link to create a query to create a list to create a parameter to use in the next query" and couldn't find anything that fits the scenario above.


Thanks so much for your time and have a great day,


Lost in Power BI (Mike)

Regular Visitor

Thanks so much team!  I'm going to attempt the DataInsights suggestion.  I just need to figure out the DirectQuery to Oracle since our company doesn't allow software downloads from outside websites. I have Oracle Client installed, but I need to see if is part of that software installation. If not, I may need to utilize my AWS connection instead.  If/when I get this running, I'll make sure to post.

Super User
Super User



Mike, try this proof of concept that uses DirectQuery tables and dynamic M parameters. I'm using SQL Server, but I would expect that the solution could be applied to Oracle. The hierarchy is Contract --> Payment --> PaymentDetail. I'm referencing tables directly as opposed to using custom SQL. You could create Oracle views for each of the three tables.




Create parameters in Power Query. You can use any value for Current Value.




Bind the parameters to columns as shown below. In the Model view, click on the column and go to Advanced Properties to bind the parameter.





prmContractID --> Contract[ContractID]

prmPaymentID --> Payment[PaymentID]


In Power Query, add a step to filter rows in Payment and PaymentDetail:


Payment table

Table.SelectRows(dbo_Payment, each ([ContractID] = prmContractID))


PaymentDetail table

Table.SelectRows(dbo_PaymentDetail, each ([PaymentID] = prmPaymentID))


Create a ContractID slicer based on Contract[ContractID], and a PaymentID slicer based on Payment[PaymentID].


Create a table visual based on PaymentDetail.








Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

So, I'm almost there. I'm running into an issue when doing the following:

"In Power Query, add a step to filter rows in Payment and PaymentDetail"


The Payment table has the "source" step to get the data. I tried to create a new step called Custom1 and added the suggested SQL (I changed dbo_Payment to Source and ContractID to Struct_Doc_ID_Num).  I'm getting the following error saying I can't use Direct Query.  Any thoughts?? 


Thanks so much,








Are you using custom SQL or referencing database tables/views directly? If custom SQL, you'll need to add the parameter name to the SQL.

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

This is what's in the source step with the "bolded" text has been updated to make general:


= Oracle.Database("ORACLE_DATABASE", [HierarchicalNavigation=true, Query="SELECT PYMT_PKG_ID_NUM, STRUCT_DOC_ID_NUM#(lf) FROM ORACLE_SCHEMA.V_ORACLE_VIEW#(lf)"])

Omg, it worked!!  Thank you thank you thank you.


Ok crew, for anyone who does this in the future, follow all the wonderful steps provided by DataInsights. The only change I needed to make was when the following was stated: 

"In Power Query, add a step to filter rows in Payment and PaymentDetail"

I actually had to not add a step.  Instead, within my primary step, I needed to reference the parameter. Please see the code below.  



= Oracle.Database("ORACLE_DATABASE", [HierarchicalNavigation=true, Query="SELECT PYMT_PKG_ID_NUM, STRUCT_DOC_ID_NUM FROM ORACLE_SCHEMA.V_ORACLE_VIEW WHERE STRUCT_DOC_ID_NUM = '"&prmContractID&"' #(lf)"])



Glad to hear it worked! To clarify, there are two ways to achieve this:


1. Referencing database tables/views directly (my approach): adding the Power Query step to filter rows is necessary.


2. Custom SQL (your approach): instead of adding the Power Query step to filter rows, reference the parameter in the custom SQL.


Keep in mind that if you add any Power Query steps after custom SQL, query folding will cease (degrades performance). Referencing database tables/views directly may improve performance depending on how Oracle caches query plans. Also, there are security advantages to using views since a DBA can control access to the views.


I believe you can simplify your custom SQL by removing the trailing line feed character:




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Yeah, totally agree there are two different ways depending on what you need to accomplish. Thanks for the heads up on performance issues I need to look out for and good point on removing the trailing line feed.


Have a great day!!!!



Super User
Super User

@embassy17orders , I doubt you can do that- Passing slicer value to source connection. It is only possible if you using a direct query and the dynamic M parameter is supported

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors