Countif A condition is met

I have a worksheet that contains weekly stats for NFL teams. One of the cells for each week returns "true" if they won or "false" if they lost. The true or false is generated by a formula that compares points for vs. points against. That is working fine, but...

I am trying to get a season summary sheet to add the number of Trues (wins) for each team and the formula only returns "0". I have tried Count, Countif, Countmatches and Sum with Countif nested within the function. A similar formula works fine that counts the number of "yes" to the question did they cover for each week. I'm stuck.

Mac Studio, macOS 12.6

Posted on Oct 18, 2022 11:48 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 18, 2022 5:05 PM

It appears that the team names are in Weekly Stats::Table 1::I and the Win true/false is Weekly Stats::Table 1::U. I do not see where any team names are in your summary table nor do I know what column is the count of wins for each team. I will say the team names are in column A and the count of wins (where the formula needs to be) is in B


Column B formula in the summary table =COUNTIFS(Weekly Stats::Table 1::I,A,Weekly Stats::Table 1::U, TRUE)


This says to count the instances where the team name in Weekly Stats::Table 1::I is the same as the team name in Summary::A (the cell on the same row as the formula) AND the value in Weekly Stats::Table 1::U is TRUE.

8 replies
Question marked as Top-ranking reply

Oct 18, 2022 5:05 PM in response to kah89

It appears that the team names are in Weekly Stats::Table 1::I and the Win true/false is Weekly Stats::Table 1::U. I do not see where any team names are in your summary table nor do I know what column is the count of wins for each team. I will say the team names are in column A and the count of wins (where the formula needs to be) is in B


Column B formula in the summary table =COUNTIFS(Weekly Stats::Table 1::I,A,Weekly Stats::Table 1::U, TRUE)


This says to count the instances where the team name in Weekly Stats::Table 1::I is the same as the team name in Summary::A (the cell on the same row as the formula) AND the value in Weekly Stats::Table 1::U is TRUE.

Oct 21, 2022 3:56 PM in response to kah89

Looking back at it after seeing more of your table and finally getting what was going on, your original COUNTIF(Weekly Stats::Table 1::G07:DO7, "TRUE") formula should work if the Win columns are the only ones with "TRUE" in them and they have the string "TRUE" not the boolean value TRUE. Given that it works with "yes", it leads me to believe the Win columns have the boolean value TRUE while your formula is checking for "TRUE". However, my formula checked for the boolean value TRUE, unless you changed it to "TRUE", so I am perplexed.


Still, it is better to use COUNTIFS and check only those columns that are the Win columns.

Oct 21, 2022 10:01 AM in response to Badunit

Thanks so very much for your effort on this, unfortunately your recent formula also did not work. However, I decided that there is no reason your formula or my original should not work (it worked for covered yes, no). There must be something about true/false that keeps the formula from working. I changed the formula for the cells in column "WIN" to return a win, loss, or tie instead of True, False or Tie. I inserted that into the formula you wrote and...Viola. Haven't tried it with the original CountIF (leaving well enough alone). Just strange that the formula wouldn't recognize True and just return zero. Anyway, Thanks again for your efforts and time.


KAH

Oct 20, 2022 11:58 AM in response to kah89

The format for COUNTIFS is COUNTIFS(range, condition, range, condition,...) and it will count the instances where ALL the conditions are met. You have written it as COUNTIFS(range,range,range....., condition).


If the teams are listed in the same order in the Summary table as they are in Weekly Stats (so we do not have to find which row in Weekly Stats has that team), the formula below should work for the Patriots, then drag-fill down to do the rest of them


=COUNTIFS(Weekly Stats::Table 1::5:5,TRUE,Weekly Stats::Table 1::$4:$4,"Win")


It counts all the TRUEs on row 5 that also have "Win" in row 4.

Oct 19, 2022 9:15 AM in response to Badunit

Here are the relevant rows from the two sheets. This is the summary sheet and one of the formulas I tried (the other two listed in original post) The column "number of wins" should have a total from the CountIFS on the weekly work sheet. (see next screen shot).

I am trying to get the first sheet shown above to total the number of "TRUE" found in the Win column for all 18 weeks (the sheet goes out 18 weeks but only two shown here due to size)


Is this more helpful?

Oct 19, 2022 7:32 PM in response to kah89

I have to admit I am totally perplexed by the formula you posted in your screenshots. The outside parentheses are unnecessary, the SUM is doing nothing and is also unnecessary, and I am sorry to say the COUNTIFS part of it makes no sense with all the cell references from the same row. I am ignoring it completely. Because you do need to use the COUNTIFS formula to get your results, you really should read up on it.


EDIT (deleted the formula): The formula I posted was incorrect. I need to see all the columns of the weekly stats table. I see now that there are multiple games on each row. Your first screenshot showed games 2 and 3 (though all the info for game 3 was covered up). The second one shows games 1 and 2. I cannot write a formula without seeing all the columns (all games) and the column letters.

Oct 20, 2022 9:30 AM in response to Badunit

The formula I posted was one of three different attempts to do the same thing (none of them worked). The extra parenthesis was added by numbers. the long CountIF formula contains all of the cells where I want to look and test for"true". I tried telling it to look in a particular row for matches and it returned zero (third formula in original Post). I tried the same with COUNTIF (2nd formula in original post) and it too returned zero. I only used SUM in combo with COUNTIF because I was attempting to direct the formula to only look at the cells outlined in the first formula of the original post. I could not add individual cells to COUNTIF alone because an error message was generated based on too many arguments. In any event none of them worked. A similar formula worked for number of covers.

I don't understand why the same formula would not work when looking for "TRUE" instead of "YES". I don't think I can take a screen shot that includes all of the cells that need to be searched as it is 18 weeks long and each week contains 7 columns, but the individual cells I want tested are listed in the first formula from the original posting.


Thoughts? Thanks for looking at this.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Countif A condition is met

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.