Forum Discussion

Zdenek_Moravec's avatar
Zdenek_Moravec
Brass Contributor
Feb 17, 2022
Solved

Lookup date from one table within date range in another table

Dear colleagues,

I have a table with list of names and their vaccination date. Next table contains the names and when they were hospitalized from – to.

Vaccination table Hospital table  
Namevaccination date NameHospitalized fromHospitalized toWas hospitalized in the time of vaccination?
Adam15.02.2021 Adam01.01.202114.02.2021No
Adam15.03.2021 Bart25.02.202128.02.2021Yes
Adam15.04.2021 Cindy04.12.202110.12.2021Yes
Bart26.01.2021     
Bart26.02.2021     
Bart26.03.2021     
Cindy05.10.2021     
Cindy05.11.2021     
Cindy05.12.2021     

The task is to find for every name if the hospitality date from – to passes with the vaccination date.

I was thinking of filtering vaccination table by name and use this result in xlookup? Or double xlookup?

Thank You for any hint.

Zdenek Moravec

7 Replies

    • Zdenek_Moravec's avatar
      Zdenek_Moravec
      Brass Contributor
      @ Sergei Baklan, thank You for a modern solution. This is the way, how to learn new functions ...
    • Zdenek_Moravec's avatar
      Zdenek_Moravec
      Brass Contributor
      Hello
      Thank You very much.
      And if I want to return the passed vaccination date instead of Yes/No?
      Zdenek
      • OliverScheurich's avatar
        OliverScheurich
        Gold Contributor

        Zdenek_Moravec 

        =IFERROR(INDEX(T_Vacc[vaccination date],LARGE(IF((D3=T_Vacc[Name])*(E3>=T_Vacc[vaccination date]),ROW($1:$9)),1)),"No")

        Do you want to return the last vaccination date before the hospitalized from date? Enter formula with ctrl+shift+enter if you don't work with Office365 or 2021. 

Resources