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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi
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 Name | Account number |
| Ben | 0000123456 |
| Luke | 0000443399 |
| Fritz | 0000121112 |
Thank you so much for any input and support.
Br/Robert
Solved! Go to Solution.
Hi @BobbyDollar ,
this article describes how to achieve it: https://community.powerbi.com/t5/Desktop/Parameterized-SQL-Query-with-query-folding/td-p/171503
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
Hi @BobbyDollar ,
this article describes how to achieve it: https://community.powerbi.com/t5/Desktop/Parameterized-SQL-Query-with-query-folding/td-p/171503
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |