Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Count if entry for specific account is Failed

0

Hi Team,

I have an issue on how to return the value as 1 in case "Failed or No Show" status is available for a certain or specific account.

Attached is my sample file.

Accounts are W,X,Y,and Z. Status is given for each account as well. For column I (labelled as FAILED WITH W) a value of "1" should reflect in each row if "Failed or No Show" status has been tagged for "W" account.

formula is same with Column J, K, and L (label for each colum is already available)

Thank you in advance for helping me.

Answer
Discuss

Answers

0

Try this formula for W:

=IF(AND($A2="W",COUNTIF(OFFSET(I$1,0,0,ROW()-1),1)>0),"1",IF($A2="W",MIN(1,COUNTIF($B2:$H2,"FAILED")),""))

Put it into Cell I2 and copy it down. 

This will output 1 if there is a FAILED value in the row and the type is W and it will also check if there is any other 1 above it in the column and output 1 if that is the case. I think this is what you were trying to do.

To change for the other types, just copy the formula to the right and change W to the correct account type.

Discuss

Discussion

Hi Don,

Thanks for the answer. However, this formulas does not return a Value of 1 in case "W" account is found in Account 2,3 or 4 (Column C, E or G). I've tried NOT to put any "W" in Account1(Column A) and put "W" in Account 2 (Column C).

Note: Accounts (W,X,Y,Z) are manually entered and duplicate of account per row is not allowed 
Example: (Row - A2) contains "W", (Row - C2, E2, G2) should not have any "W account" 
(Row A3) contains "X", (Row - C2, E2, G2) should not have any "X account" 
corpuzjunel (rep: 4) Oct 11, '18 at 8:42 am
Try and add more conditions to the AND() function to check for that. So you can add like this: 

$A2="W", $C2<>"W", $E2<>"W", $G2<>"W"

That's a kind of easy way to solve the issues by making the formula bigger and without adding too much complex logic. Then, do that with the other checks.
don (rep: 1989) Oct 15, '18 at 5:20 am
Add to Discussion
0

Here is a formula you may like to use.

[I2] =IFERROR(IF(INDEX($A2:$H2,1,MATCH(I$1,$A2:$G2,0)+1)<>"PASSED",1,0),0)

Copy it from I2 to range I2:L2. In order to make the reference to I$1 work, the cell format in I1:L1 must be changed. Set a Custom cell format "FAILED WITH "@ and type W, X, Y and Z in the cells. The apperance will be the same but the cell values will only be W, X, Y and Z. As an alternative you might replace the reference to I$1 with a hard "W" and proceed analogue in the other columns so that you have a different formula in each column.

Note that the formula presumes that each account will appear only once in each row. It will count any Status which isn't PASSED as failed.

The formula will display a zero both if the account isn't found in a row and if its Status is PASSED. If you don't like to see this zero follow these steps:-

  1. Click File / Options / Advanced
  2. Look for Display options for this worksheet.
  3. Look for Show a zero in cells that have zero value and remove the checkmark.

Edit 13 Oct 2018  ================================

The formula below has been modified to write "1" in the column when the status is eitehr "Failed" or "No Show".

=IFERROR(IF(OR(INDEX($A2:$H2,1,MATCH(I$1,$A2:$G2,0)+1)="FAILED",INDEX($A2:$H2,1,MATCH(I$1,$A2:$G2,0)+1)="NO SHOW"),1,0),0)

As a matter of principle, it is best practice not to write variables into formulas. There are two variables in the above, "FAILED" and "NO SHOW". It would be better to put them in a list, possibly on another worksheet, and refer to the list in the formula.

The same goes for the reference to I$1. If you can't modify the column headers I would prefer to have the card names in a list, possibly on another sheet, and refer to that list. This is just to avoid fidgeting with the formula when the variable is changed. However, you can also replace I$1 with a string, like "MasterCard" or "Visa". The difference is whether you replace it in one location or in every formula.

At the very end of the formula you have two zeroes "NO SHOW"),1,0),0). The first one will be used if the text is neither "Failed" nor "No Show". The second and last one will be used if the card isn't found (like row 2 has no "Y"). You may wish to replace one or both of these zeroes with "" (twin quotation marks = null string)

In the attached workbook, on Sheet1(2), a formula is used that implements the suggestions made above. The tables used by this formula are on Sheet3.

Discuss

Discussion

This does not answer the "Failed" condition
corpuzjunel (rep: 4) Oct 11, '18 at 8:44 am
Sorry! I didn't pay enough attention to your worksheet. Now I have posted a revised formula which I believe will work the way you want. If it still doesn't, please modify columns I:L in your worksheet to show the desired results.
Variatus (rep: 4889) Oct 11, '18 at 10:30 pm
Raw data for this one is autogenerated by a system. with that I cant change anything from that data. Also, there are lots of Status aside from Passed and Failed.

 what i need to identify is the "Failed" status for that specific account. Regardless if its in Account1, 2, 3 or 4.

To avoid confusion. let's change Account Names W,X,Y,Z  to credit card brands such as: MasterCard, Visa, Chase, CitiBank.

For Column I:
I need a formula that will return a Value of "1" in the event that there's a failed status for MasterCard. anywhere from A:H

For Column J:
I need a formula that will return a Value of "1" in the event that there's a failed status for Visa. anywhere from A:H

Chase for Column K. and CitiBank for Column L.

Thank you so much for answering my queries Variatus.
corpuzjunel (rep: 4) Oct 12, '18 at 6:45 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login