How to use CountIf in Google Sheets that only counts cells if there is content in another cell? - google-sheets

I need some help with a CountIf type formula in Google Sheets.
I have a large spreadsheet of a consolidated NHL schedule where I am going to enter stats that I care about. In a separate spreadsheet I am going to have averages for the stats I care about.
I want to have a formula that uses the Column A of Sheet2 to count the games in Sheet1 that have content in the other cells of Sheet1 (so, games that have been played).
If this works then Column B of Sheet2 will have the correct # of games played which is all the cells that have content/stats next to the teams name in Sheet1 so that I dont have to manually update that part and then the count of games played can go straight to the average formula.
The pictures are manually entered but just showing that since the Blackhawks have content next to their name in Sheet1, I would want Sheet2 Column B to read 1 based on a formula.
Thanks!!!
Sheet1
Sheet2

I would just do a COUNTA on a column (so that counts the rows in a specific column that are not blank), on a filtered table that match the team names:
So:
=COUNTA(FILTER(Sheet1!D:D,Sheet1!B:B=A3))

Related

Google Sheets formula help - total the number of X in a specific data range from another sheet

I have a spreadsheet with multiple pages. on page one i have a chart with row values of months and column values of different subjects.
i would like to have a formula that supplies a live update of all instances of X in a specific data range on page one and the data on page two. (ie: total number of times "Apple" is listed in column B for the month of august, date in column A).
of note: data is added to the top of this sheet every day, so the cells need to be dynamic
thank you for your assistance.

I need a Google Formula that counts cells that meet two conditions in a range

I have a spreadsheet that I am running reports on. I need to count some data within the B column. The data is within the same column on the same sheet tab.
This formula below looks in the B column and counts C.
=COUNTIF('Google Sheet Tab1'!B1:B1071,"C")
This didn't work either
=COUNTIFS(Google Sheet Tab1!B1:B1071,"C",Google Sheet Tab1!B1:B1071,"N")
I need a formula that looks for C and N and adds them together and displays them.
The easiest way would be to add both conditions.
Please try
=COUNTIF('Google Sheet Tab1'!B1:B1071,"C")+COUNTIF('Google Sheet Tab1'!B1:B1071,"N")
COUNTIFS would need to satisfy both conditions at the same time.
Read more about it.

Finding non zero row number in a google sheet from another sheet

I've looked on stackoverflow and Google forums for an answer to this but couldn't quite find what I wanted.
I have numerous sheets with different names, such as "members", "officers", "trustees" etc and each one has columns for peoples names, followed by birthdates, addresses etc. (each sheet has no header). I am trying to find the number of occupied rows in each sheet from another sheet, to give the number of people.
So, for instance, if I have a sheet called "numbers", the A1 would be the number of non-zero rows in "members", the B1 would be the same for "officers" etc.
I've referenced cells in other sheets before by doing something like =members!A14 but I don't know how to find the row number of the last row from another sheet. Can anyone help please? Ideally, I'd like this to be a formula rather than a function call.
This will count the number of non-blank cells in column A on the sheet named members.
=counta(members!A1:A)

If a value in a cell has a duplicate within same column, delete both cells

What I want to happen is if a value on Sheet1 exists in Sheet2, I want them both to delete. Essentially, i want a list of cells that do not exist in both sheets. I have queried an array that combines two columns on different sheets. I am just stumped on how to delete both cells (automatically) if they exist twice.
For reference, the first sheet has a list of incoming product's serial numbers, The second sheets has a list of those same products that are now going out. I want an active list of what i have in-house.
Sheet one
Sheet two
Sheet three combining the both
This formula will work
=query({incoming!B:B, outgoing!C:C}, "select Col1 where Col1 <> Col2",0)
Assume we have an 'incoming' sheet for incoming products, and 'outgoing' sheet for outgoing products.
Assume we want to list on 'stock', all the stock that has come in, but has not gone out - in effect a list of the stock on hand.
The formula is entered anywhere in the "stock" sheet.
Layout of the "incoming" sheet
Layout of the "outgoing" sheet
Results in the "Stock" sheet
The query uses curly brackets to group together two arrays. This is described (albeit briefly, in Using arrays in Google Sheets.
The stock codes on the "incoming" sheet will include all products, regardless of whether they are outgoing, or they are still on hand. So we compare the codes in this array to the "outgoing" codes and apply the criterion of "where Col1 <> Col2". That is, where the code is in 'incoming" but not in "outgoing".

Setting formula range from first to last populated cell in a column?

For a league I run we keep track of games played and w/l/t and calculate that into a ranking score. The player name is listed in column U and the ranking score in column AD of a fixed table. I then use an array formula to list the players in ranking order in column E (then vlookup to pull in other stats based on the value in E for that row). Specifically I use this formula in column E:
=ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX($U$4:$U$153,MATCH(LARGE($AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),ROW(E72)-ROW(E$4)+1),$AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),0))), 1, 1)
I need to be able to add players to the table in U:AD without having to edit the formula every time, i.e. from $U4:$U153 and $AD$4:$AD$153 to $U4:$U154 and $AD$4:$AD$154 in all the various places in the formula then copy the new formula all the way down.
Is there a way that I could define the range as $U$4:$U(last populated row) and the same for column AD in the above formula?
I eventually be using this in both Excel and Google Sheets so I would really like to avoid scripting. First I'm looking to solve this for Google Sheets.
Here is a copy of the sheet I am working on.
You could use INDEX and COUNTA
Instead of $U4$U153,
$U4:INDEX(U4:U,COUNTA(A4:A))
The COUNTA portion will give the number of populated rows and feed it into INDEX to give $U4:$U153
The answer for the Google sheet that you shared.
skip to the end for the simple solution
I used the indirect method by entering a formula in E1 that counts the AD column for player stats and adds 3 to get the last row. (I was going create the full range AD4:AD?? but you also have U4:U73 in the formula)
=counta(AD4:AD)+3
I then changed your formula use indirect, indirect("$AD$4:AD"&E$1), to reference the last row number in cell E1 to create the required range.
=iferror(ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX(indirect("$U$4:U"&E$1),MATCH(LARGE(indirect("$AD$4:AD"&E$1)-ROW(indirect("$AD$4:AD"&E$1))/COUNT(indirect("$AD$4:$AD"&E$1)),ROW(E4)-ROW(E$4)+1),indirect("$AD$4:$AD"&E$1)-ROW(indirect("$AD$4:$AD"&E$1))/COUNT(indirect("$AD$4:AD"&E$1)),0))), 1, 1),"")
I discovered by accident that if you remove the ARRAY_CONSTRAIN from your formula and change U4:U73 to U4:AC73 then the formula will populate the scores to the right of your formula where you currently have vlookups. I put an example of this in E4 but note that you will have to delete the vlookup formulas if you want to fill the formula down otherwise it will show REF
I also added iferror so that the formula can be copied to the same row as the end of the "open slots" in column A without showing errors.
Also, I got to this point and was thinking that since you're using Google Sheets, a better way to do this could be to use the QUERY function to pull the data and also sort it using ORDER BY with a single formula in cell E4.
I've not really used the QUERY function but maybe it's time to learn.
EDIT
Turns out it doesn't take much learning
=QUERY(U4:AD,"SELECT U,V,W,X,Y,Z,AA,AB,AC ORDER BY AD DESC")
Put the formula above in cell E4 and delete everything beneath and scores to the right and you're done. you'll notice that there is no indirect because Google understands that you don't want the blank rows.
https://docs.google.com/spreadsheets/d/16IclEmKwDFdInIAZhH2vt-tLJ5pbwX06jv9xrUXwhnY/edit?usp=sharing
Why are you using $ signs around U4:U153,remove $ signs for rows that will give you flexibility while keeping columns fixed.As your drag the formula,the data array will append the newly filled cells or you can create table using Ctrl+T that will automatically expand as you keeping adding data.

Resources