简体   繁体   English

如果条件不起作用,索引与数组公式匹配吗?

[英]Index match array formula with if condition not working?

I have 2 worksheets in an excel workbook. 我在Excel工作簿中有2个工作表。 Sheet 'Data' and sheet 'Home'. 工作表“数据”和工作表“主页”。

Data: 数据:

Column B (Lookup Value)          Column C (Criteria)         Column D (Criteria)      COLUMN E (Criteria)         Column F
329115121601                     3291                        5555                     15/12/16                    50 <---- Week Number from date

On my other sheet, 'Home' i am trying to look up the number from column B using an index match (array formula) where the values match those in column C and D and E or F. 在我的另一张纸上,“ Home”我试图使用索引匹配(数组公式)从B列中查找数字,其中的值与C列,D和E或F列中的值匹配。

Home: 家:

Column H      Column I      Column J                   Column K
3291          5555          15/12/2016 or Week 50      {=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}

I am nesting an if statement within my index match to try and allow the user to enter either the specific date or the week number of that date. 我在索引匹配项中嵌套了一个if语句,以尝试允许用户输入特定日期或该日期的星期数。 The user should be able to enter either week number or a specific date and get a result. 用户应该能够输入星期数或特定日期并获得结果。

For some reason, this formula works if the user enters a week number, but not if they enter a specific date. 由于某种原因,如果用户输入星期数,则此公式有效,但如果输入特定日期,则该公式无效。 Please can someone show me where i am going wrong? 请有人能告诉我我要去哪里错吗? Thanks 谢谢

EDIT 编辑

I am getting my date '151216' from a string in column B. like so: 我从B列中的字符串获取日期“ 151216”,如下所示:

Data: (Formula View) 数据:(公式视图)

Column B            Column E (UK Date Formatted as DD/MM/YYYY)              Column F (Week Num) 
329115121601       =DATE("20"&MID(B8,9,2),MID(B8,7,2),MID(B8,5,2))         =IF(F8<>"",WEEKNUM(F8,21),"") 

Data: (Value View) 数据:(值视图)

Column B            Column E (UK Date Formatted as DD/MM/YYYY)     Column F (Week Num) 
329115121601        15/12/2016                                     50

My week number formula in column F produces a value error when the date is entered with this formula as 15/12/2016. 当使用此公式将日期输入为15/12/2016时,F列中的我的周数公式会产生值错误。 No week number is produced. 没有周数产生。 Likewise, if the date is typed in as 15/12/2016 i get a value error in column F and no week number is produced. 同样,如果将日期键入为15/12/2016,则在F列中会出现值错误,并且不会生成周数。

However, If i enter my date in column E as 12/15/2016 manually, without the formula this renders as 15/12/2016 and a week number of 50 is shown in column F. 但是,如果我在E列中手动输入我的日期为2016年12月15日,则不使用公式将其显示为2016年12月15日,在F列中显示为50的星期数。

Then on my home sheet, column J is date formated DD/MM/YYYY for UK and i must enter the date in column j as 12/15/2016 which will render as 15/12/2016 and then this way i get a result. 然后在我的主页上,J列的日期格式为DD / MM / YYYY(对于英国),我必须在j列中输入日期为12/15/2016,这将呈现为15/12/2016,然后通过这种方式我得到一个结果。 So there must be a problem with the formula in column E i suppose? 我想E列中的公式一定有问题吗?

users will be entering the date in column J on Home sheet as 15/12/2016 not 12/15/2016. 用户将在首页的“ J”列中输入日期为15/12/2016,而不是12/15/2016。 So What can i do to fix this? 那么,我该怎么做才能解决此问题?

It seems you need to have the right return_type for the Gregorian Calendar and ISO 8601 standard. 看来您需要为Gregorian Calendar和ISO 8601标准使用正确的return_type。 Included in Excel 2010. 包含在Excel 2010中。
WEEKNUM(Home!$J10,21) WEEKNUM(主页!$ J10,21)

{=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10,21))=Data!$F:$F),0)),"No Po Found")}

在此处输入图片说明

Strange for me the function seems to work fine. 对我来说奇怪的是,该功能似乎正常工作。 Did you check if the seperated WEEKNUM(Home!$J10,21) function returns the correct weeknumber. 您是否检查了单独的WEEKNUM(Home!$ J10,21)函数是否返回了正确的星期数。
Because WEEKNUM(Home!$J10) without return_type=21 the weeknumber produced is 51 instead of 50 which we want. 因为WEEKNUM(Home!$ J10)没有return_type = 21,所以生成的周数是51,而不是我们想要的50。

Also try this one. 也试试这个。

{=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,ISOWEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}

在此处输入图片说明 在此处输入图片说明

It matches the data correctly even if the data is US format and input in UK format. 即使数据是美国格式并以英国格式输入,也可以正确匹配数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM