Table.SelectRows IF parameter not equal...

kcmuppet

Active Member
Joined
Nov 2, 2005
Messages
439
Office Version
  1. 365
Platform
  1. Windows
Hello

I'm trying to filter by the field named Clinic based on the value of a text parameter, named p_SelectedClinics, if its value isn't "All", but struggling with the syntax.

This gives me "Expression.SyntaxError: Token Comma expected." and wiggly line under 'then'

Power Query:
 #"Filtered Rows" = Table.SelectRows(#"Changed Type",  each If [p_SelectedClinics] <> "All" then [Clinic] = p_SelectedClinics),

How should it be written?

My next line is a filter which does work, but ideally all the filtering would be one step

Power Query:
#"Filter by dates" = Table.SelectRows(#"Filtered Rows", each [Date] >= p_ReportStartDate and [Date] <= p_ReportEndDate),

Guidance greatly appreciated!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I couldn't work out how to do it so went with this in the end:

Power Query:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each p_SelectedClinic = "All" or [Clinic] = p_SelectedClinic and [Date] >= p_ReportStartDate and [Date] <= p_ReportEndDate)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,753
Messages
6,174,307
Members
452,554
Latest member
Louis1225

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
Back
Top