Pull time off data based on the name and date range from another sheet

I have two sheets; one is a PTO calendar where team members enter name, a date, and days of time off. The sheet then calculates the hours of time off. I have another sheet that is broken down by name, project, and weeks (Mondays are the column header, i.e. 1/1, 1/8, etc...).

I want to be able to pull the time off hours from the PTO calendar and populate in the other sheet. The criteria are name and range of dates. I've tried INDEX, and COLLECT, and I can't seem to get it to work. Has anyone had a similar issue? What was the solution?

Best Answer

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    Answer ✓

    No worries. Lets get started with a few helper columns. We will have one for each potential week that could be overlapped. Assuming a maximum of 56 working hours, this means in theory there could be a maximum of 3 calendar weeks touched by the vacation. Once we get these working, we can move on to your second screenshot and get those calculations going.


    First would be [Week 1 Hours] and use this column formula:

    =MIN(((MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 7) - [PTO Date]@row) + 1) * 8, [PTO Hours]@row)


    Next would be [Week 2 Hours] and use this column formula:

    =IFERROR(MIN(((IF(WEEKNUMBER(MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 14)) <> WEEKNUMBER([PTO Date]@row), MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 14)) - IFERROR([PTO Date]@row + (2 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) < 2, 7, 0) + 7, "")) + 1) * 8, [PTO Hours]@row - MIN(((MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 7) - [PTO Date]@row) + 1) * 8, [PTO Hours]@row)), "")


    And finally will be [Week 3 Hours] and use this column formula:

    =IFERROR(MIN(((IF(WEEKNUMBER(MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 21)) <> WEEKNUMBER(IFERROR([PTO Date]@row + (2 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) < 2, 7, 0) + 7, "")), MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 21)) - IFERROR([PTO Date]@row + (2 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) < 2, 7, 0) + 14, "")) + 1) * 8, [PTO Hours]@row - (MIN(((MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 7) - [PTO Date]@row) + 1) * 8, [PTO Hours]@row) + IFERROR(MIN(((IF(WEEKNUMBER(MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 14)) <> WEEKNUMBER([PTO Date]@row), MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 14)) - IFERROR([PTO Date]@row + (2 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) < 2, 7, 0) + 7, "")) + 1) * 8, [PTO Hours]@row - MIN(((MIN(WORKDAY([PTO Date]@row, [PTO Hours]@row / 8), [PTO Date]@row + (6 - WEEKDAY([PTO Date]@row)) - IF(WEEKDAY([PTO Date]@row) <= 6, 7, 0) + 7) - [PTO Date]@row) + 1) * 8, [PTO Hours]@row)), ""))), "")

«1

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!