How to specify "All" or a single option with a select statement

I have the select statement below in use to generate csv files. It references a parameters table to grab the start date, end date, division and a few other parameters for the select statement. It works great but I’d like the statement to display data when a “division” is select or “All” records when no division is selected. How do I adjust the expression below for this functionality?

<Start:ORDERBY(Select(Collection[collection_id],AND([vir_route_date]=[start_date_time],[vir_route_date]<=[end_date_time],[vir_route_div]=[division])),[Date Time Entered],FALSE)>>

Try:

<<Start:ORDERBY(SELECT(Collection[collection_id], AND([vir_route_date] = [start_date_time], [vir_route_date] <= [end_date_time], OR(ISBLANK([division]), [vir_route_div] = [division]))), [Date Time Entered])>>

I strongly recommend you add some dereferences of [_THISROW] in there if you aren’t actually comparing values entirely within the row.

2 Likes