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

Frequent Visitor

Query to source with parameter from another table (Account IDs)



Hope anybody can help me and my question is reasonable.


In Power Query I connect to a new source with below string. The SQL string within includes here 3 Account IDs (RC Number).

But I do not want to have fixed accounts in the query. The query should be flexible and pull the accounts from another table within power query. In addition the number of accounts might be different (not 3 always but 5 accounts) which I query.


Original Query





= OleDb.DataSource("provider=MSOLAP.8;...", [Query="SELECT {[Measures].[Sell Out Quantity],[Measures].[Sell Out Amount]} ON COLUMNS , NON Empty  Hierarchize({DrilldownLevel({[RC Account].[RC Number].&[0000159985],[RC Account].[RC Number].&[0000199622],[RC Account].[RC Number].&[0000283464]})}) ON ROWS  FROM  (SELECT ({[Currency].[Currency].&[EUR]}) ON COLUMNS FROM [Data-CUBE])  WHERE ({[_Empty Cube].[Empty Cube].&[No]},{[Sell Out Data].[Data Source].&[SellOutFiles]},{[Sell Out Data].[Sales Doubled].&[N/A],[Sell Out Data].[Sales Doubled].&[Not Sales Doubled]},{[Sell Out Data].[Sales Type].&[N/A],[Sell Out Data].[Sales Type].&[Sales]},{[Sell Out File Data].[Flat File Type].&[],[Sell Out File Data].[Flat File Type].&[QUO],[Sell Out File Data].[Flat File Type].&[SAL]}) CELL PROPERTIES VALUE"])






Example for table which holds the accounts to be used in above query and might change with a refresh.

Account NameAccount number


Thank you so much for any input and support.



Super User
Super User

Super User
Super User

Hi @BobbyDollar ,

this article describes how to achieve it:


Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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
Top Kudoed Authors