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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
arpost
Advocate V
Advocate V

Is it possible to create M query steps dynamically?

I have a scenario where I am needing to essentially create dynamic query steps based on a source table. In effect, this is "build-a-bear" but for Power Query.

 

For example, let's say my query initially just loads data from a DB:

 

arpost_0-1636500115840.png

 

I want to then allow an end user to add an item to a table that indicates we need to filter a column. Imagine something like this:

UserActionColumnValue
Joe SchmoeFilterCustomerTailspin Toys (Head Office)

 

I want my query to then "add" a query step that applies a filter:

arpost_1-1636500308311.png

Is something like this possible perhaps with functions or recursive function execution or something? Kind of like building a dynamic SQL query.

 

 

4 REPLIES 4
mahoneypat
Employee
Employee

Sounds like you need to use parameters.

Parameters | Microsoft Docs

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for the reply, @mahoneypat! I'm sure parameters will play a part, but the issue is the number of filters to be applied could change as could the type of steps needed.

 

In the example above, a user may want to filter data to a specific customer when viewing a report one week but next week add filters that filter customer, product, and region. I need to not have to manually add filter logic that looks at all of those columns. He or she could even want to group by, say, product category, which isn't in the original query and is where (I'm hoping) the recursive behavior or custom function comes in.

Have you considered just loading all the data and then having all potential fitlers as slicers (or Filter panel options)?  

 

You could also consider using paginated reports with parameters too.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for the response! This isn't a visualization-first report but actually needs to be fully dynamic on the query/ETL side as this could extend to complex scenarios like user-defined merges between tables and duplicate removals. My hope is to create a dataflow that will let users alter the data loaded into a table dynamically using an app as a kind of business logic/rules engine.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors
Top Kudoed Authors