Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a table in Excel I am extracting rows from user Power Query. I also have an input cell on the output worksheet where a user can enter a value to filter the results. I have successfully set the power query perform the filter if the input cell is populated. However, if the user leaves the filter value blank, Power Query does not return any rows.
I would like to allow the user to leave the filter value blank and return all rows from the query. However do not know how to conditionally apply a filter in Power Query.
Any idea?
Solved! Go to Solution.
You can add a step with a condition like this:
if MyParameter <> null then PreviousFilteredStep else PrePreviousUnfilteredStep
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
You can add a step with a condition like this:
if MyParameter <> null then PreviousFilteredStep else PrePreviousUnfilteredStep
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
I was just trying to figure out how to do this best myself, and found this reply.
I am wondering whether declaring it this way will actually lead to the filter in the previous step being executed, and then the conditional parameter line evaluated? Or whether the mashup engine is smart enough to postpone evaluating the filter until it knows it needs to?
I'm writing mine as;
if MyParameter <> null then ( .. filter expression ) else previousunfilteredstep
... just in case
?
Yes, M is a partially lazy language. So it will mostly only evaluate what's actually needed.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
101 | |
86 | |
77 | |
69 |
User | Count |
---|---|
120 | |
108 | |
98 | |
83 | |
77 |