Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Return value based off multiple conditions

$
0
0

I have this formula I am trying to get working but I am struggling to do so for an unknown reason. I wondered if anybody on here might be able to help. I am starting to think this may not be totally possible in Google Sheets.

To summarise, I am looking for the formula to do the following.

  • Check the date shown in K12 on current sheet (adjusts to cells when dragged).
  • Then go to sheet called "Booked" and find the date from K12 in between the range BE40:CI59.
  • When it finds the date, it should check the check in date shown in W40:W59 and if the date also matches that then display "CHECK IN:" before returning the final result.
  • If it does not match the check in date, also check the check out date found in Z40:Z59 and if it matches that then display "CHECK OUT:" before the final result.
  • If it finds neither match for the check in or check out date then it should just pull the final result.
  • To get the final result, it should go along that row with the date in and pull the hotel name found in E40:E59.
  • If it doesn't find a matching date at all, it should say "No hotel found".

The final result should read one of four possible outcomes.

  1. CHECK IN: (hotel name)
  2. CHECK OUT: (hotel name)
  3. (hotel name)
  4. No hotel found

Currently, I am at this point, it is finding the matching hotel but is not putting check out or check in first (i've not yet told it to because I wanted to just give a working formula for part of it right now).

=IFERROR(FILTER(Booked!$E$40:$E$59, (K12 >= Booked!$BE$40:$BE$59) * (K12 <= Booked!$CI$40:$CI$59)), "No hotel found.")

enter image description here

As you can see above, it is displaying the hotel names for Friday 04 Aug, 2023 up till Monday 07 Aug, 2023. This is a changeover day, so it has seen that the date features twice as as a check in and check out date so therefore has displayed both hotel names. However, it has continued to also do that for the dates beyond that and I am unsure why.

I hope makes sense, I have tried to explain it as simply as possible.

Link to spreadsheet

Here is a link to the spreadsheet to help you understand. If anyone can help that would be great, perhaps it is easier to break into two formulas that check one above the other or perhaps not.

Thanks in advance.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>