SOLVED
Home

Need Nested IF Formula to Count Data Only, Not Formulas

%3CLINGO-SUB%20id%3D%22lingo-sub-755306%22%20slang%3D%22en-US%22%3ENeed%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755306%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20cannot%20figure%20out%20how%20to%20get%20my%20formula%20to%20account%20for%20data%20returned%20from%20another%20cell%2C%20not%20it's%20formula.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'll%20attempt%20to%20explain%20simply%2C%20I%20have%20sets%20of%205%20water%20samples%20per%20fixture%20that%20have%20two%20different%20range%20results.%20%26lt%3B5%20isn't%20accounted%20for%2C%20%26gt%3B5%20-%20%26lt%3B14.99%20is%20medium%20levels%20of%20danger%2C%20and%20%26gt%3B15%20is%20high%20levels%20of%20danger.%20These%20sample%20results%20are%20in%20column%20A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20column%20B%20and%20C%2C%20I%20created%20a%20total%20count%20of%20each%20type%20of%20level%20with%20a%20COUNTIF%20function.%20Column%20B%20is%20medium%20(later%20noted%20with%20%22YELLOW%22)%2C%20so%20if%202%2F5%20samples%20are%20medium%20level%2C%20it%20will%20display%202%2C%20and%20column%20C%20is%20high%20(later%20noted%20with%20%22RED%22)%2C%20so%20if%201%2F5%20samples%20is%20high%2C%20it%20will%20display%201.%3C%2FP%3E%3CP%3EHere%20are%20the%20column%20B%20and%20C%20formulas%3A%3C%2FP%3E%3CP%3E%22YELLOW%22%3DCOUNTIFS(A2%3AA6%2C%22%26gt%3B5%22%2CA2%3AA6%2C%22%26lt%3B14.99%22)%3C%2FP%3E%3CP%3E%22RED%22%3DCOUNTIF(A2%3AA6%2C%22%26gt%3B15%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhere%20it%20gets%20tricky%20is%20Column%20D%2C%20which%20I%20want%20to%20let%20me%20know%20if%20a%20single%20fixture%20contains%20%22YELLOW%22%2C%20%22RED%22%2C%20or%20%22BOTH%22%20sample%20levels%20within%20the%20set%20of%205.%26nbsp%3B%20I%20need%20to%20know%20this%20because%20we%20need%20to%20count%20how%20many%20fixtures%20specifically%20contain%20medium%20or%20high%20levels%2C%20not%20how%20many%20SAMPLES.%20You%20can%20see%20it%20would%20be%20confusing%20to%20say%20we%20had%203%20samples%20with%20high%20levels%2C%20because%20it%20sounds%20like%203%20different%20fixtures%20had%20high%20levels%2C%20when%20really%20all%20three%20samples%20were%20from%20a%20single%20fixture.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20created%20a%20nested%20IF%2FAND%20statement%20that%20works%20perfectly%20when%20columns%20B%20and%20C%20are%20%22plain%22%20data%20with%20no%20COUNTIF%20formula%20calculating%20the%20number.%20However%2C%20I%20cannot%20do%20it%20that%20way%20and%20I%20need%20to%20use%20a%20formula%20to%20count%20the%20samples%20in%20each%20category.%20Here%20is%20the%20formula%20created%3A%3C%2FP%3E%3CP%3E%3DIF(AND(B2%3D%22%22%2CC2%26lt%3B%26gt%3B%22%22)%2C%22YELLOW%22%2CIF(AND(B2%26lt%3B%26gt%3B%22%22%2CC2%3D%22%22)%2C%22RED%22%2CIF(AND(B2%26lt%3B%26gt%3B%22%22%2CC2%26lt%3B%26gt%3B%22%22)%2C%22BOTH%22%2C%22NEITHER%22)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20I%20keep%20encountering%20is%2C%20this%20column%20D%20formula%20keeps%20counting%20the%20formula%20used%20in%20columns%20B%20and%20C%20as%20text%2C%20and%20the%20results%20keep%20returning%20as%20%22BOTH%22%2C%20because%20the%20field%20is%20never%20really%20blank%20because%20of%20the%20formula%20inside%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20the%20column%20D%20formula%20to%20count%20the%20DATA%20ONLY%20in%20column%20B%20and%20C.%20Can%20anyone%20PLEASE%20help%20with%20this%3F%3F%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-755306%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755337%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755337%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F376636%22%20target%3D%22_blank%22%3E%40stamez%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EIt%20would%20be%20quite%20helpful%20if%20you%20share%20the%20file%20or%20some%20sample%20data.%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755350%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755350%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239215%22%20target%3D%22_blank%22%3E%40tauqeeracma%3C%2FA%3E%26nbsp%3BAttached%20is%20a%20sample%20set!%20The%20only%20difference%20is%20the%20results%20column%20is%20now%20column%20Q%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755358%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755358%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239215%22%20target%3D%22_blank%22%3E%40tauqeeracma%3C%2FA%3E%26nbsp%3BI%20forgot%20to%20change%20it%20back%20but%20I%20changed%20the%20sheet%20to%20leave%20a%20cell%20blank%20if%20the%20result%20was%20%220%22%2C%20and%20I%20still%20had%20the%20same%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755451%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755451%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F376636%22%20target%3D%22_blank%22%3E%40stamez%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20apply%20to%20the%20column%20General%20format%20instead%20of%20Text.%20Formula%20is%20like%3C%2FP%3E%0A%3CPRE%3E%3DIF(AND(Y2%3D0%2CZ2%26lt%3B%26gt%3B0)%2C%22YELLOW%22%2CIF(AND(Y2%26lt%3B%26gt%3B0%2CZ2%3D0)%2C%22RED%22%2CIF(AND(Y2%26lt%3B%26gt%3B0%2CZ2%26lt%3B%26gt%3B0)%2C%22BOTH%22%2C%22NEITHER%22)))%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755464%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BOkay%2C%20I%20had%20it%20that%20way%20before%20and%20still%20the%20same%20issue%2C%20I%20was%20just%20changing%20up%20formatting%20types%20to%20see%20if%20it%20made%20a%20difference%20and%20it%20doesn't.%20Still%20the%20same%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755469%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755469%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F376636%22%20target%3D%22_blank%22%3E%40stamez%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDid%20you%20check%20the%20file%20I%20attached%20in%20previous%20post%3F%20It%20show%20different%20result.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755488%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755488%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BOh!%20I'm%20sorry%20I%20didn't%20see%20you%20had%20actually%20adjusted%20the%20formula%20and%20not%20the%20column%20formatting.%20Yes%2C%20that%20solved%20the%20problem%20thank%20you%20so%20much!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-755517%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Nested%20IF%20Formula%20to%20Count%20Data%20Only%2C%20Not%20Formulas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-755517%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F376636%22%20target%3D%22_blank%22%3E%40stamez%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E
stamez
Occasional Contributor

Hello,

 

I cannot figure out how to get my formula to account for data returned from another cell, not it's formula.

 

I'll attempt to explain simply, I have sets of 5 water samples per fixture that have two different range results. <5 isn't accounted for, >5 - <14.99 is medium levels of danger, and >15 is high levels of danger. These sample results are in column A

 

In column B and C, I created a total count of each type of level with a COUNTIF function. Column B is medium (later noted with "YELLOW"), so if 2/5 samples are medium level, it will display 2, and column C is high (later noted with "RED"), so if 1/5 samples is high, it will display 1.

Here are the column B and C formulas:

"YELLOW"=COUNTIFS(A2:A6,">5",A2:A6,"<14.99")

"RED"=COUNTIF(A2:A6,">15")

 

Where it gets tricky is Column D, which I want to let me know if a single fixture contains "YELLOW", "RED", or "BOTH" sample levels within the set of 5.  I need to know this because we need to count how many fixtures specifically contain medium or high levels, not how many SAMPLES. You can see it would be confusing to say we had 3 samples with high levels, because it sounds like 3 different fixtures had high levels, when really all three samples were from a single fixture.

 

I have created a nested IF/AND statement that works perfectly when columns B and C are "plain" data with no COUNTIF formula calculating the number. However, I cannot do it that way and I need to use a formula to count the samples in each category. Here is the formula created:

=IF(AND(B2="",C2<>""),"YELLOW",IF(AND(B2<>"",C2=""),"RED",IF(AND(B2<>"",C2<>""),"BOTH","NEITHER")))

 

The problem I keep encountering is, this column D formula keeps counting the formula used in columns B and C as text, and the results keep returning as "BOTH", because the field is never really blank because of the formula inside it.

 

I need the column D formula to count the DATA ONLY in column B and C. Can anyone PLEASE help with this???

 

8 Replies

@stamez 

 

Hello,

It would be quite helpful if you share the file or some sample data. 

Thanks

@tauqeeracma Attached is a sample set! The only difference is the results column is now column Q

@tauqeeracma I forgot to change it back but I changed the sheet to leave a cell blank if the result was "0", and I still had the same problem.

Solution

@stamez 

First, apply to the column General format instead of Text. Formula is like

=IF(AND(Y2=0,Z2<>0),"YELLOW",IF(AND(Y2<>0,Z2=0),"RED",IF(AND(Y2<>0,Z2<>0),"BOTH","NEITHER")))

 

@Sergei Baklan Okay, I had it that way before and still the same issue, I was just changing up formatting types to see if it made a difference and it doesn't. Still the same problem.

@stamez 

Did you check the file I attached in previous post? It show different result.

@Sergei Baklan Oh! I'm sorry I didn't see you had actually adjusted the formula and not the column formatting. Yes, that solved the problem thank you so much!!!