简体   繁体   中英

Cannot fix array formula sum with if statement

I have an ARRAYFORMULA that adds up a whole column of data based on a condition, but I need to adjust the formula separately so it adds up the data based on two conditions. It works with only one condition but when I try to adjust it stops working.

This is the formula that works:

=ARRAYFORMULA(SUM(IF(All!$AI3:$AI <> "GB", All!$J3:$J, "0")))

It adds up the value of all items in a column that do not contain "GB". AI is the column that contains the country code (including GB) and column J contains the value of that item.

I want it to add up all the items that do not contain GB, from a certain date range.

I tried to adjust the formula like this:

=ARRAYFORMULA(SUM(IF(OR(REGEXMATCH(All!$C$3:$C$11000, A6), All!$AI3:$AI <> "GB"), All!$J3:$J, "0")))

So it checks if column C contains the date held in A6, and if column AI contains "GB", then theoretically should add up the result. When I use OR it adds up every single value in column J. When I use AND instead of OR the result is 0.

Any help would be greatly appreciated!

Edit for clarification:

I am using REGEXMATCH because I only need to check if column C contains what is in A6 - the dates in C have year, month, day and time, I only need to check if it contains the year and month.

UPDATED (base on comment of OP)

See if this works..

=sumproduct(text(B:B; "mm/yyyy")=text(A1; "mm/yyyy");D:D<>"GB";E:E  )

or

=sumproduct(year(B:B)=year(A1); month(B:B)=month(A1);D:D<>"GB";E:E  )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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