Filter for multiple date ranges

%3CLINGO-SUB%20id%3D%22lingo-sub-2328442%22%20slang%3D%22en-US%22%3EFilter%20for%20multiple%20date%20ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2328442%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20building%20a%20template%20and%20in%20this%20template%20I%20have%20multiple%20fields%20for%20different%20parameters%20that%20will%20need%20to%20be%20filtered.%20One%20filter%20is%20for%20time%20and%20I'm%20having%20trouble%20figuring%20out%20how%20to%20filter%20multiple%20time%20periods%20i.e.%20filter%20out%20data%20from%20times%20between%207-9AM%20and%201-2PM.%20I'm%20able%20to%20filter%20for%20one%20period%20but%20have%20not%20been%20able%20to%20figure%20how%20to%20do%20more%20than%20one%20without%20using%20VBA%2C%20because%20I%20don't%20know%20how%20to%20use%20VBA.%20Any%20help%20would%20be%20appreciated%20and%20if%20more%20information%20is%20needed%20to%20help%20solve%20this%2C%20please%20let%20me%20know.%3CBR%20%2F%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2328442%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338409%22%20slang%3D%22en-US%22%3ERE%3A%20Filter%20for%20multiple%20date%20ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338409%22%20slang%3D%22en-US%22%3Edo%20you%20have%20a%20sample%20file%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2393743%22%20slang%3D%22en-US%22%3ERE%3A%20Filter%20for%20multiple%20date%20ranges%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2393743%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1046166%22%20target%3D%22_blank%22%3E%40jjulien03%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdvanced%20filtering%20disappeared%20on%20my%20system%20i'll%20have%20to%20wait%20for%20it%20to%20come%20back%20whenever%20uncle%20MS%20returns%20the%20feature%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I'm building a template and in this template I have multiple fields for different parameters that will need to be filtered. One filter is for time and I'm having trouble figuring out how to filter multiple time periods i.e. filter out data from times between 7-9AM and 1-2PM. I'm able to filter for one period but have not been able to figure how to do more than one without using VBA, because I don't know how to use VBA. Any help would be appreciated and if more information is needed to help solve this, please let me know.
Thanks

5 Replies
do you have a sample file

@Yea_So Yes, A2 on the filtered data tab is where the formula is located. Cells C12-C15 on the Filters&Results tab are the input cells I'd like to use. Thanks for taking a look

Hi @jjulien03 

 

Advanced filtering disappeared on my system i'll have to wait for it to come back whenever uncle MS returns the feature

Hi @jjulien03 

 

What I created for your filter problem is not a formula based solution, but rather a power query solution.

Step 1. I converted your Raw Data Adjusted into a table and did a power query to it:

Yea_So_0-1622170630552.png

then I created a parameter table to connect your Filters&Results sheet where you enter your search parameters and called it ParamConnector.

Yea_So_1-1622170747380.png

then I did a power query on the Parameter table

Yea_So_2-1622170845890.png

and made three references to it and named them:

Search1Results, Search2Results, and Search3Results

Yea_So_3-1622170943134.png

On Search1Results I did the following:

1 I added a custom column then entered M language to select the rows as prescribed in the 1st Shade Omissions Period start and end dates:

Yea_So_4-1622171157135.png

the M Language: 

Table.SelectRows(
RDA,
(InnerTable) => InnerTable[Date] >= [SD] and InnerTable[Date] <= [ED] and InnerTable[Time] >= [R1S] and InnerTable[Time] <= [R1E]
)

SD=Start Date

ED=End Date

R1S= Start Time Range number 1 in Filter&Results Sheet 

R1E= End Time Range number 1 in Filter&Results Sheet

Repeat and Rinse for the other 2 Search2Results and Search3Results making sure the variable references are referening the correct parameters. (Check it in the Added Custom step in the Query Settings navigation panel by clicking the gear setting beside it)

 

After all three search results have been done, I then did a Merge query >Append on all three parameter queries Search1Result, Search2Results, and Search3Results.

Yea_So_5-1622171760994.pngYea_So_6-1622171798740.png

then I Closed & Loaded to the worksheet and named it 3VectorSearchResults sheet:

Yea_So_7-1622171866399.png

Here is the file => My Template Neer Cap Test  

 

When you enter new parameters in your Filter&Results Sheet, press ctrl+alt+F5 to refresh the query.

 

if you have any questions please feel free to reach out.

 

cheers

 

@jjulien03 

I think there were errors in the way in which elements of the filter criterion were formulated.  Additional parentheses were needed.

=FILTER(siteTime#:finalColumn,
     (Date#<=endDate)*(Date#>=startDate)
    *((Time#>eT₁)+(Time#<sT₁))
    *(POA#>=minIrr)
    *((Time#>eT₂)+(Time#<sT₂)))

I converted the raw data to an Excel table and started building the derived data as dynamic arrays with a defined name applied to the anchor cell for reference purposes.