Forum Discussion
Multiple queries with multiple parameters
Here's a detailed and professional response you can post:
Hi All,
Thank you for the suggestions provided so far.
Let me explain my scenario in more detail.
I have a Power BI report with multiple slicers (for example: Region, Country, Business Unit, Date Range, Product Category, etc.). These slicers are currently built using a static/disconnected table.
Behind the report, I have 4-5 custom SQL queries (DirectQuery) that retrieve data from different database tables/views. My requirement is to pass the user-selected values from these slicers into all of these custom queries so that the filtering happens at the database level before the data is returned to Power BI.
The main reason for this requirement is performance optimization:
- Some of the custom queries are quite complex and involve multiple joins and aggregations.
- A few queries already take a considerable amount of time to execute at the database level.
- Currently, the queries fetch a larger dataset and the filtering is applied later within Power BI.
- When multiple users access the report simultaneously, multiple complex queries run against the database, resulting in increased database load and slower report performance.
Ideally, I am looking for something similar to:
- User selects values in slicers.
- Selected values are passed as parameters to all relevant custom queries.
- Database returns only the filtered subset of data.
- Power BI renders the report using that reduced dataset.
For example:
- Region = APAC
- Country = India
- Business Unit = Sales
These selected values should be available inside multiple custom SQL queries and be used within the WHERE clause during query execution.
I have explored dynamic M query parameters, but my understanding is that there are limitations when multiple slicers need to drive multiple custom queries simultaneously.
My primary goal is to push the filtering logic to the source database and avoid retrieving unnecessary data into Power BI.
Any guidance, implementation examples, or recommended approaches would be greatly appreciated.
Thanks in advance!