Filtering based on a dropdown list in Power Query

stags81

New Member
Joined
Dec 10, 2010
Messages
18
Hello,

I am using Power Query to pull multiple data sets into a single workbook. I have a table within that workbook that contains a dropdown. What is selected in that dropdown determines how the data pulled in by Power Query gets filtered. See attached for further explanation.

It works perfectly, but I'd like to take it to the next level. If a user selects "All" in the dropdown, I would like Power Query to simply disregard the input variable and display all rows. Is this possible to write in M code?

e.g.
#"Filtered Rows" = Table.SelectRows(#"Reordered Columns1", each if ([Supplier Name] = "All" then Table.DisplayAll else [Supplier Name] = Supplier)),

If more info is needed, please don't hesitate to ask. I'm just trying to be mindful of the information I share here.

Thanks in advance,

Mike
 

Attachments

  • Capture.JPG
    Capture.JPG
    241 KB · Views: 20

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

billszysz

Active Member
Joined
Feb 26, 2014
Messages
382
Office Version
  1. 365
Power Query:
#"Filtered Rows" = if Supplier = "All" then #"Reordered Columns1" else Table.SelectRows(#"Reordered Columns1", each [Supplier Name] = Supplier),
 
Solution

Forum statistics

Threads
1,141,485
Messages
5,706,654
Members
421,459
Latest member
Taamrak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top