方程式简化

时间:2018-07-05 21:50:39

标签: excel excel-formula

有什么想法可以简化这个方程式吗?每个地区(亚太地区,拉美,欧洲,中东和非洲,北美)的标准各不相同(小时/天的截止时间)。

信不信由你,这曾经更长。这是我的最佳尝试:

按组划分:

=IF(A2="","",

IF(WEEKDAY(B2,2)=6,"Weekend Case",

IF(AND(C2<>"APAC",WEEKDAY(B2,2)=7),"WeekendCase", 

IF(AND(C2="APAC",OR(AND(WEEKDAY(B2,2)=5,HOUR(B2)>=3),AND(WEEKDAY(B2,2)=7,
HOUR(B2)<18))),"Weekend Case",

IF(AND(C2="North America",OR(AND(WEEKDAY(B2,2)=5,HOUR(B2)>=18),
AND(WEEKDAY(B2,2)=1,HOUR(B2)<8))),"Weekend Case",

IF(AND(C2="EMEA",OR(AND(WEEKDAY(B2,2)=5,HOUR(B2)>=10),
AND(WEEKDAY(B2,2)=1,HOUR(B2)<2))),"Weekend Case",

IF(AND(C2="LATAM",OR(AND(WEEKDAY(B2,2)=5,HOUR(B2)>=15),
AND(WEEKDAY(B2,2)=1,HOUR(B2)<5))),"Weekend Case",

"Weekday")))))))

逻辑:

如果A2 = NothingNothing

所有地区:
如果SatWEEKEND

北美,欧洲,中东和非洲,拉美
IF SunWEEKEND

亚太地区:
如果Friday After 3AMSunday Before 6PMWEEKEND

北美:
如果Friday After 6PMMonday Before 8AMWEEKEND

EMEA:
IF Friday After 10AMMonday Before 2AMWEEKEND

拉美:
如果Friday After 3PMMonday Before 5AMWEEKEND

其他:
 WEEKDAY


每个区域的示例,每个输出如下:

enter image description here

2 个答案:

答案 0 :(得分:2)

如果您可以使用外部表进行查找,则应该能够简化它(并在需要时使其更易于更改)

查询表:

enter image description here

数字是星期一(col I)和星期五(col J)要抵消的天数。也就是说,对于亚太地区,+ 6小时为=6/24天,而+21小时为=21/24天。 (请确保使用此表的公式,而不要使用四舍五入的数字)

然后您可以使用以下公式:

=IF(AND(WEEKDAY(B2+VLOOKUP(C2,H$2:J$5,2))>=1,WEEKDAY(B2+VLOOKUP(C2,H$2:J$5,3))<=5),"Weekday","Weekend Case")

我得到的结果与您的样品相同。

答案 1 :(得分:1)

创建一个称为Schedule的参考表,并按如下所示加载它:

     A            B        C
1 Region       WE-start  WE-end
2 APAC           503      718
3 EMEA           505      802
4 LATAM          515      805
5 North America  518      818

WE值的格式为dhh,其中d =工作日,hh =小时。如果工作日是星期日,则将其强制为8,以简化计算。

以下公式将生成您的类型并更正EMEA。

=IF(AND(IF(WEEKDAY(B2)=1,700,0)+WEEKDAY(B2)*100+HOUR(B2)>=VLOOKUP(C2,Schedule!$A$2:$C$5,2), IF(WEEKDAY(B2)=1,700,0)+WEEKDAY(B2)*100+HOUR(B2)<VLOOKUP(C2,Schedule!$A$2:$C$5,3)),"Weekend Case","Weekday")