Using OR logic on an array as argument in Sumproduct

后端 未结 7 562
南旧
南旧 2021-01-12 04:47

I\'m having a fairly large dataset where I need to combine multiple entries into a single value. My dataset contains data on the combination of two datasets, each using thei

7条回答
  •  一整个雨季
    2021-01-12 05:21

    You can use text search for this:

    --NOT(ISERROR(FIND('Raw data'!O:O,"2021222340")))
    

    But you have to be careful that a shorter ID is not found incorrectly in a longer ID, e.g. if you want to search among the IDs { 123, 456, 789 } then 12 is not considered to be among the IDs. So a simple text search like the above would not work. You need a delimiter character to break up the string of IDs. Usually I use the pipe character for this purpose, since I cannot remember any case when it occurred in the original text of an Excel file, and because it makes the formula human-readable:

    --NOT(ISERROR(FIND("|"&'Raw data'!O:O&"|","|20|21|22|23|40|")))
    

    Examples:

    'Raw data'!O:O is 20 => |21| is found in |20|21|22|23|40|

    'Raw data'!O:O is 2 => |2| is not found in |20|21|22|23|40|

    (If your IDs may include the pipe character, then you can use CHR(1), a long forgotten ASCII code for SOH meaning start of header; of course, it's less readable.)

    The whole formula:

    =SUMPRODUCT(--('Raw data'!C:C=Landgebruik!A2),--NOT(ISERROR(FIND("|"&'Raw data'!O:O&"|","|20|21|22|23|40|"))),'Raw data'!S:S)
    

    (Sorry, my Excel uses , instead of ;)

提交回复
热议问题