Copy value from a cell if start and end date are in a certain month

I am trying to copy the "Contract Value" number to the January, February etc cell if the start and end date are between the corresponding month.

E.g The first row shows a start date of 06/01/22 (Australian date format DD/MM/YY) and end date 31/03/22. This should copy the contract value of $417,168.62 to the January, February and March cells.


Best Answers

  • KPH
    KPH ✭✭✭✭✭✭
    Answer ✓

    Hi @Benji241

    How about a SUMIFS formula like this:

    =SUMIFS([Contract Value]:[Contract Value], [Start Date]:[Start Date], MONTH(@cell) <= 1, [End Date]:[End Date], MONTH(@cell) >= 1)

    This sums the Contract value column of all rows where the month of the start date is equal to or before month 1 and the month of the end date is equal to or after month 1.

    You would change the 1 (in bold) to 2 for February, 3 for March, etc.

    This will result in an error if either date column is blank so you might want to wrap it in an IFERROR, like this:

    =IFERROR(SUMIFS([Contract Value]:[Contract Value], [Start Date]:[Start Date], MONTH(@cell) <= 1, [End Date]:[End Date], MONTH(@cell) >= 1), "")

  • Benji241
    Benji241 ✭✭
    Answer ✓

    Ok I think I have solved this. It was the dates that were the wrong way around. This is the formula that worked for me. (so far anyway)

    =IF(AND($[Start Date]@row <= DATE(2023, 1, 31), $[End date]@row >= DATE(2023, 1, 1)), $[Contract Value]@row, "")

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!