Excel - CountIfs (column A has target value, column B is blank) - excel

First post, sorry if it's not according to site preferences. I searched around and couldn't find a post that was exactly like this, but sorry if this is a repeat as well.
I have the following code:
=COUNTIFS(A:A,"="&C3, B:B,"<>""")
For clarity, the code is supposed to identify instances where column A has a specific value (C3), and where column B is empty.
I'm familiar with Countifs, but it was the "if blank" portion that I've been really struggling with. On top of that, column B is populated with formulas, making this seemingly more challenging from my perspective as a couple methods I've tried only work if the cells are truly unpopulated. What I can say is that this formula is working with almost all of my examples, except 1, and I have no idea why this would be. For that matter I'm not entirely sure why this code works at all.
Any insight would be greatly appreciated.
Thank you very much.

To count if blank: "="
=COUNTIFS(A:A,"="&C3, B:B,"=")
Or if this is easier to understand:
=COUNTIFS(A:A,"="&C3, B:B,"=" & "")
Which is the same.

"=" in COUNTIFS does not match blanks that result from formulas. Dont ask me why!
As workaround, you can use the flexible and never vexing SUMPRODUCT:
=SUMPRODUCT((A:A=C3)*(LEN(B:B)=0))

Related

EXCEL Averaging with multiple Criteria

I have tried 2 approaches to my problem and can't quite figure out where I'm going wrong.
=AVERAGEIFS(CALC!L:L,CALC!C:C,Consignee!A2,CALC!K:K,CALC!A:A) and =IF(AND(Consignee!A2=CALC!C:C,CALC!K:K=CALC!A:A),AVERAGE(CALC!L:L),0)
Basically I need to start with CONSIGNEE!A2, then find it's match in CALC!C:C, which I then need to check against CALC!A:A to find the ones that go with it in the same row and see if that/those cell(s) match any in CALC!K:K and then take the average of the corresponding values in CALC!L:L and average them. I hope that makes sense. I feel like I've gotten close but am missing something.
Thank you in advance for your help!
I suspect that the formula below may not be the most efficient possible but it will do the job.
=SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2),CALC!L:L)/SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2))
Edit
In my original answer a reference to L1 was erroneously left over from the formula I tested where I had L1 taking the place of CONSIGNEE!A2. I have corrected this error and believe that the formula works fine for your requirement now.
Note that there are two separate SUMPRODUCT functions which you can test each by itself, one returning the count, the other the sum. If the count = 0 a #DIV/0 error will occur. You can prevent that by embedding the formula in and IFERROR() function.

Shortening COUNTIF formulas in Excel

I'm not sure if this is a duplicate question, I've tried looking around but I don't see any duplicates. Pardon me if I'm wrong.
I've got a simple formula that I stacked many times to give me my end result, but I feel like it's too long.
I have 2 questions:
1) What can I do to shorten this super-long mess of a formula I've come up with; and
2) Is there a better way to do it?
I need someone to at least point me in the right direction to get started.
This is the formula: =IF((COUNTIF(B1:B10,"VC1"))=1,IF((COUNTIF(B1:B10,"VC2"))=1,IF((COUNTIF(B1:B10,"VC3"))=1,IF((COUNTIF(B1:B10,"VCG1"))=1,IF((COUNTIF(B1:B10,"VCG2"))=1,IF((COUNTIF(B1:B10,"X"))=1,IF((COUNTIF(B1:B10,"XM"))=1,IF((COUNTIF(B1:B10,"XG"))=1,IF((COUNTIF(B1:B10,"P"))=2,"10","P"),"XG"),"XM"),"X"),"VCG2"),"VCG1"),"VC3"),"VC2"),"VC1")
Basically, I have text in cells B1 to B10, each with unique values.
In case it's needed, the values are (not in order): X, XM, XG, VCG1, VC1, VC2, VC3, VCG2, P, P.
A different cell will have the formula that I mentioned, to ensure that each cell has a very specific text defined, or else it'll show an error message.
Because of this, I also have another question:
3) What can I do to make it such that I can search (or COUNTIF) all the values from B1 to B10, and make sure that there's an exact number of values with very specific texts inside, without it going in order of the formula?
To explain this further, the formula does an IF, then a COUNTIF. If the COUNTIF succeeds, it will move on to the next COUNTIF inside the value for the result. Because of this, I can't print multiple "errors" at once, and it goes for each "error" one by one, which can be confusing to the end user.
It might be something else than what you want, but what if you use something like this?
=(COUNT(B1:B10;"VC1")=1)*1&
(COUNT(B1:B10;"VC2")=1)*1&
(COUNT(B1:B10;"VC3")=1)*1&
(COUNT(B1:B10;"VCG1")=1)*1&
(COUNT(B1:B10;"VCG2")=1)*1&
(COUNT(B1:B10;"X")=1)*1&
(COUNT(B1:B10;"XM")=1)*1&
(COUNT(B1:B10;"XG")=1)*1&
(COUNT(B1:B10;"P")=2)*1
it would create a string of zeroes and ones (false and true) and from this you would be able to identify if something is wrong and even how many errors occured and why.

Excel: If vlookup returns specific text, countifs number of instances (multiple)

First post, but I am stuck and was hoping for some help. What I am trying to do is use a nested IF formula to determine whether the value returned by a VLOOKUP matches specific text on another sheet in the same workbook. If it does, to then use the COUNTIFS function to determine the sum of instances that specific text contained in a specific cell appears on another sheet (also in the same workbook).
One part of these formulas seems to work, but when I combine it with others, it errors and I can't figure out why.
It's probably something simple, but I'd appreciate any help. Here's the part that seems to "work"
=IF(VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="All",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")
+
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")))
If I put one more parenthesis, it works as is, but seems to omit some of the "All" Vlookup results... thus why I put works in quotations above. That might be an issue with my spreadsheet though, but felt I should include in case I'm just being idiotic. Regardless, when I input two additional IF statements, it errors.
The final formula I've crafted looks like this (double spaced for ease of reading only):
=IF(VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="All",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")
+
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")))),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="One",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="Two",
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY"),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="Three",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")),"0"))
Any ideas?
Thanks!
Ryan Olson
Just cleaned up some bracketing. Let me know how it goes as I didn't alter the formula otherwise.
=IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="All",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY")+(COUNTIFS(Sheet2!$R:$R,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY")),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="One",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="Two",
COUNTIFS(Sheet2!$R:$R,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="Three",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),"0"))))

Counting Cells in a Range that Contains Formulas, Only when a Date is Returned?

Frequent browser, first time poster. Please go easy:
I have spent the last few days searching online, and on here for a solution to a problem I have encountered for the first time. I have a report that pulls from multiple worksheets. One column is a formula that does a VLOOKUP to another sheet and pulls back a date, if it exists. I then have a cell at the top of the sheet that calculates how many dates are pulled back out of all of the rows (to calculate % complete). This is where I am having the problem. I have tried variations of COUNTIF, COUNTA, COUNTBLANK, and so on, and formulas trying to reverse calculate,
=SUM(C4)-COUNTIF(Table3[2014 Process Date],"")
At first it appeared to work, but in this example, I had 1949 rows, and dates only populated in 7 of those rows. In theory it should return 7. Instead it is returning 237. I have done multiple filters, and manually reviewed the data in the column, and only 7 dates are there. The column has the VLOOKUP in and IFERROR nest,
=IFERROR(VLOOKUP(A12,Table_TaxData.accdb3[#All],240,FALSE),"").
I am guessing I am overlooking something silly, and was hoping someone would be able to help steer me in the right direction, or let me know what I am missing. Thanks in advance for any help!
Wow, looks like I need some more coffee! Thank you, I guess I assumed that it would be much more complicated than that. I just threw in
=COUNT(Table3[2014 Process Date])
And it worked like a charm! Thanks again!
If I'm reading your formula correctly, the target cells hold either the DATE, or a blank "".
If so, you can do a COUNTIF and do this:
=COUNT(B:B)
to get # of dates.
or
=COUNTA(B:B)-COUNT(B:B)
to get # of blanks.
(I used column B, not sure where your final values are in you're looking for - adjust accordingly)

Showing New and Old by Date using Excel

long time no chat, I am running into a situation in where a formula I wrote up seems not to be working correctly. I know it's probably me, but logic based programming seems to be the bane of my existence.
=IF(D1>2010,"New",IF(D1<2010,"Old",""))
Is the formula in question, now if I got this down correctly, which I thought I did, is that if D1 is greater than the year 2010 the cell would say New, and if it's less than 2010, it would say Old.
It's not working, for some reason I can't figure out why.
I have a similar formula that works:
=IF($B155<>"","Full",IF($J155<>"","Full","Empty"))
I figured the logic would be similar, it seems I'm wrong. Can someone help me solve this simple quandary, logic based math has never been my strong suit. Thanks.
If D1=2010, there's no true condition in IF clauses, and the result will be a blank cell ("").
=IF(D1>=2010,"New",IF(D1<2010,"Old","")) should do the trick.
If D1 is formatted as a Date, the following formula will give the desired result:
=IF(YEAR(D1)>=2010,"New",IF(YEAR(D1)<2010,"Old",""))

Resources