代码之家  ›  专栏  ›  技术社区  ›  Maxim Srour

基于时间和日期列出计划中的值

  •  0
  • Maxim Srour  · 技术社区  · 6 年前

    我有一组原始数据存储在一个表中,使用的标题是

    1. Name, String             //Name of employee
    2. Job, String              //The job site they are on
    3. Start Date (SD), Date    //Starting date
    4. End Date (ED), Date      //Ending date
    5. Start Time(ST), Time     //Start time each day
    6. End Time (ET), Time      //End time each day
    7. Saturday, Bool           //Whether they will be onsite on Saturday
    8. Sunday, Bool             //Same as above
    

    在Excel工作表中,我有一个这样格式化的表

    Raw data

    Working Schedule Spreadsheet

    在每个单元格中,我当前都有这个数组输入的公式

    =IFNA(INDEX(INDIRECT(Cells!$B$2), MATCH(1, ($A3 = INDIRECT(Cells!$A$2)) * (C$1 >= INDIRECT(Cells!$C$2)) * (C$1 < INDIRECT(Cells!$D$2)) * ($B3 >= INDIRECT(Cells!$E$2)) * ($B3 < INDIRECT(Cells!$F$2)), 0)), "")
    //The INDIRECT references the input table
    

    这目前有效,但不检查员工是否安排在周六或周日(默认为假)。它的工作方式是对列出的所有变量进行多变量索引匹配。我不知道怎样才能包含布尔位。

    我现在的问题是如果我再加上 (TEXT(C$2, "ddd") = INDIRECT(Cells!$G$2)) 在比赛中,只有这样才有效 一个星期六,所以有一个类似的声明,以检查星期天将不会显示。

    Broken Schedule Spreadsheet using second formula

    我希望这是合理的,如果需要,我可以提供更多的信息。谢谢

    1 回复  |  直到 6 年前
        1
  •  1
  •   jblood94    6 年前

    添加一些条件。

    =IFNA(INDEX(INDIRECT(Cells!$B$2),MATCH(1,($A3=INDIRECT(Cells!$A$2))*(C$1>=INDIRECT(Cells!$C$2))*(C$1<INDIRECT(Cells!$D$2))*($B3>=INDIRECT(Cells!$E$2))*($B3<INDIRECT(Cells!$F$2))*IF(WEEKDAY(F$1)=7,INDIRECT(Cells!$G$2),1)*IF(WEEKDAY(F$1)=1,INDIRECT(Cells!$H$2),1),0)),"")