需要编写一个公式,使用 C5 和 D5 中提供的支付期日期返回“支付期开始”日期。给定支付期的天数为 E5(截至撰写本文时,当前为 14 天)。因此,我需要找到输入到 C 列的日期的 14 天期间的开始日期。
需要将其写为一个沿列输出的数组公式。
我相信我能够回答我自己的问题:
=LET(dateOutsidePeriod, $C$8:$C, periodBegin, $C$5, periodEnding, $D$5, numDaysInPeriod, DATEDIF(periodBegin, periodEnding, "D") + 1, numDaysBetweenEndOfPeriodAndInput, ARRAYFORMULA(IF(dateOutsidePeriod = "", ,IF((dateOutsidePeriod >= periodBegin)*(dateOutsidePeriod <= periodEnding), "In Current Period", DATEDIF(IF(dateOutsidePeriod >= periodEnding, periodEnding, dateOutsidePeriod), IF(dateOutsidePeriod >= periodEnding, dateOutsidePeriod, periodEnding), "D")))), numPeriodsBetweenEndOfPeriodAndInputedDate, ARRAYFORMULA(IF(numDaysBetweenEndOfPeriodAndInput = "", ,IFERROR(IF(dateOutsidePeriod >= periodEnding, ROUNDUP((numDaysBetweenEndOfPeriodAndInput)/numDaysInPeriod), ROUNDDOWN((numDaysBetweenEndOfPeriodAndInput)/numDaysInPeriod)) , "In Current Period"))),numDaysBetweenEndOfOayPeriodAndEndOfLandingPeriod, ARRAYFORMULA(IF(numPeriodsBetweenEndOfPeriodAndInputedDate = "", ,IF((numPeriodsBetweenEndOfPeriodAndInputedDate <= 0)+(numPeriodsBetweenEndOfPeriodAndInputedDate = "In Current Period"),"In Current Period" ,IFERROR((numPeriodsBetweenEndOfPeriodAndInputedDate*numDaysInPeriod)*IF(dateOutsidePeriod >= periodBegin, 1, -1))))), finalResult, ARRAYFORMULA(IF(numDaysBetweenEndOfOayPeriodAndEndOfLandingPeriod = "", ,IF((numDaysBetweenEndOfOayPeriodAndEndOfLandingPeriod = "In Current Period"),periodBegin ,IFERROR(periodBegin + (numDaysBetweenEndOfOayPeriodAndEndOfLandingPeriod))))), finalResult)