Link to home
Start Free TrialLog in
Avatar of xenium
xenium

asked on

Creating complex filters in Google sheets

hi,

This post is a question and solution in one. I will post my solution as the first comment, but welcome any other input in case it helps me or any others with the same kind of problem.

Creating complex filters in google sheets can be messy because:
1. there is no commenting facility within the formulae so complex expressions will quickly get messy
2. currently logical expressions AND OR etc cannot be processed directly within ARRAYFORMULA, so this logic must be expressed using a numeric approach.

Example
Scenario: property rental business needs to assess unoccupied periods coming up in the next 14 days
Solution: query list of bookings to see what gaps are, or are coming up in the next 14 days

Not very pretty solution, filter bookings where:
(IF( (IF((round(now())<=BOOKINGS!B:B),1,0) + IF(((round(now())+14)>BOOKINGS!B:B),1,0) )=2, 1,0) + IF( (IF((round(now())>BOOKINGS!B:B),1,0) + IF((round(now())<BOOKINGS!C:C),1,0) )=2, 1,0) )>0      

This expression is explained in detail via the link posted in the first comment.

Note:
BOOKINGS!B:B = Checkout date
BOOKINGS!C:C = Next check-in date

Any better suggestions (using google sheets only)?
Avatar of xenium
xenium

ASKER

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.