Counting correlated checkboxes - google-sheets

If I have a row of checkboxes which indicate especially important columns in a sheet, how do I count for each row how many of the relevant checkboxes are ticked.
For example:
If the top row tells me that I am especially interested in the answers in columns 3, 6, 9, 13 & 15, I would like for each row to do a calculation that tell me how many of the corresponding checkboxes in that row are NOT selected.
In this example, running the calculation on row two should produce a result of 2, as the checkboxes in this row are not selected in the case of the 'important' columns 6 and 13.
The same calculation performed on row three should produce the result 0, as all of the 'important' columns have their checkboxes selected in row 3.
I'm looking for an answer that doesn't require a lot of brute force ANDing or ORing, since the columns are likely to change fairly often. A good answer would have something like the form:
"For this row, how many of the checkboxes between in columns 1 to 19 are unchecked where the corresponding checkbox in row 1 is checked"
(If it helps, the spreadsheet is for comparing product features between different offerings. there's a product on every row, while each column represents a feature. I want to be able to select the 'must have' features in row one, and get a number for each product that tells me how many of the key features it is missing. The contract goes to the reasonably-priced product that returns 0).
tia

Since we are comparing 1st row vs another row, a way to solve this is by using ARRAYFORMULA and subtracting 1st row with the current row.
Since ticked checkboxes are TRUE, it has a numerical value of 1. And if we subtract 1st row and the current row, (the unticked current row is 0) then it will result into 1.
With this in mind, we just need to count how many are there that results to 1.
Final Formula:
=COUNTIF(ARRAYFORMULA(C$1:U$1 - C2:U2), "=1")
Output:
Note:
Since row 3's 3rd column is not ticked, result should be 1 instead of 0 which you mentioned mistakenly in your post above.

Related

How to Count cells since the last filled cell in a column, and repeat for each time a cell is filled

I have a tracking spreadsheet to track dry streak calcs for certain drops from a boss in a video game. I want to be able to easily see my dry streaks by having the sheet count the amount if boss kills since the last drop.
I have the following:
=IF(B2="",COUNTBLANK(B2:INDEX($B2:B,MATCH(FALSE,($B2:B=""),0))),"")+1
where column A is the boss kill count, and column B is filled if a drop is received.
the above formula works to an extent of what i want, but the order is upside down. I'd also like it to only show the "count since last drop" when a cell in column B is filled., rather than every cell showing it.
Example sheet
If column A is a sequence of numbers as depicted in the sample you can use formula 1 and formula 2 is stand-alone just based on column B. Please test them out.
formula 1:
=let(a,filter(A2:A,B2:B="drop"),byrow(A2:A,lambda(z,IF(offset(z,,1)="drop",z-xlookup(offset(z,-1,),a,a,,-1),))))
formula 2:
=let(a,filter(row(B:B)-1,B:B="drop"),byrow(B2:B,lambda(z,IF(z="drop",row(z)-1-xlookup(row(offset(z,-2,)),a,a,,-1),))))
Here you have another option that instead of looking for values it just makes a cumulative count.
=SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))
B1:INDEX(B:B,ROWS(B:B)-1) is a replacement for OFFSET so it is a bit more economic in resources
Then you can just hide the values when B is empty:
=INDEX(IF(B2:B="","",SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))))

Problem with incrementing of a cell in a google sheets offset formula

I have three formulas, relatively the same, but with a different column for each.
=OFFSET('War Layouts'!$B$2,(ROW(B1)-1)*7,0)
=OFFSET('War Layouts'!$F$2,(ROW(F1)-1)*7,0)
=OFFSET('War Layouts'!$J$2,(ROW(J1)-1)*7,0)
The formula's do exactly what I want, but I want to copy them down my column to repeat the functionality.
When I copy them down, the row number changes to (B4),(F4),(J4), etc. And nothing else increases, which is what I want.
I want the row value to be (B2),(F2),(J2) when I copy down the formula and I just cannot wrack my brain on how to achieve this.
Edit: For additional information, i'm providing a spreadsheet example of what i'm working with.
https://docs.google.com/spreadsheets/d/1Fxc4KcAYlh7vfg7UV0oestKdyuf0LrpvzJmyt0JbAzg/edit?usp=sharing
Essentially I want pull the 'Name' Field, 3 time's a week, every 7 rows.
So day 1 is the B column, Day 2 is F, Day 3 is J.
On the 'Stats' Sheet, is where I have the formula's above. The first 3 row's are correct, but the next three have B4,F4,J4 instead of B2,F2,J2, etc.
This may do what you want, similar to what WOUNDEDStevenJones has described. Since dragging down will normally increment the row numbers in the equations by 1, use INDIRECT to calculate the new row number, based on the current row number divided by 3. The only trick is factoring in your starting row. Here are the three new formulae to replace your existing formulae:
=OFFSET($B$2, ROW( INDIRECT("B" & INT((row()+2)/3))) *7 , 0)
=OFFSET($F$2, ROW( INDIRECT("F" & INT((row()+2)/3))) *7 , 0)
=OFFSET($J$2, ROW( INDIRECT("J" & INT((row()+2)/3))) *7 , 0)
If you put these anywhere on rows 1,2 and 3 (one above the other), they can be dragged down as a group of three. You can test it out by taking just one part, =ROW( INDIRECT("B" & INT((row()+2)/3))), and dragging this down. You'll see it increments the row number by one every three rows.
The only trick is getting the starting value right. If you don't want to place the first formula in row 1, you need to adjust the "+2" amount downwards by 1, for each row you move down. So +1 if starting on row 2, +0 if on 3, -1 if on 4, etc.
Let me know if this helps, or if you need more explanation.

How to calculate the number of spaces available in a music class - Google Sheets?

My partner runs music classes for groups of kids and uses Google Sheets as a register. Kids sign up, stop coming, or come back all the time, so we have been hiding the rows in each sheet as and when necessary. We would now like a cell on each sheet (note: each class has it's own sheet) to show the number of spaces available which is updated each time new kid(s) are added or when a row is hidden because kid(s) have stopped attending.
I have tried using the below to show the number of spaces. 16 spaces in each class, minus the number of kids in column B.
=16-COUNTIF(B2:B100,"<>")
The problem is that this calculates the number of spaces with the hidden rows included, throwing up weird results, like minus numbers of spaces available.
How can I add on the number of hidden rows to the above formula?
This solution takes the suggestion by HaPhan and structures it in systematic way.
Consider the screenshot below.
1 - Green Box: there is an extra column ("Status") to record attendance information about a student.
2 - Orange Box: These are the data values for the cells in the "Status" column. All the cells in the Status Column are drop downs. This ensures consistency of spelling, categorisation, etc.
3 - Blue Box: Filters are turned on. In the "Status" column, this allows the questioner to deselect "Finished" and "Stopped" students; which would show only those students who are paid up and attending.
4 - Purple Box: These are totals for the various conditions in the "Status" column. The actual formula is described in column D.
5 - Red Box: A simple summary showing the number of seats in the class that can be sold. Assuming a maximum class size of 16 (manual data entry into cell C6) minus the number of "paid up students (a calculated value from cell C4) gives the number of available seats.
The option to filter rather than hide is significant since "selecting" and "deselecting" is extremely easy, but also automatically covers the entire column. "Hiding" and "unhiding" rows is haphazard; it can be difficult to tell whether one has found all the relevant rows.

Specify Column Range Except Second-to-last Row

I am currently using SUM on an entire column with the following formula:
=SUM(A2:A)
Unfortunately this total is displayed on the last row of this column, so it creates a circular reference, #REF, there that I need to get rid of. How can I make it so that it selects the column starting from the second row until the second-to-last?
I could change the formula manually every time I enter a new row, but that's not ideal at all.
Pseudocode
=SUM(A2:A[last row - 1])
See if this works
=sum(indirect("A2:A"&row()-1))

Google Sheet Sum Row: Count if above or below criteria

I am trying to create a summary row in a google sheet that tallies up how many cells met their criteria. These criterion are set in 2 columns to the left; Column C is the "Goal" column, which has the goal number. Column D is the "MinMax" column, which determines if that goal number is the min or max.
For example, if the Goal is 5 and the MinMax is Max, then the goal is 5 or less (5 being the maximum number allowed).
I already have successfully created conditional formatting for this sheet, which looks like the following:
=IF($D4="Min",E4>=$C4,E4<=$C4) | Turn cell green
I am struggling to find a way to use a similar calculation for the Summary row. I feel like I might need an array formula, but I'm not sure how to set it up.
If you want to count the values try:
=if(D2="Max",countif(E2:E,">="&C2),countif(E2:E,"<="&C2))
If you want to sum them useL
=if(D2="Max",sumif(E2:E,">="&C2),SUMIF(E2:E,"<="&C2))
I actually figured out a formula!!
=countif(ARRAYFORMULA(if($D$4:$D$19="Min",E$4:E$19>=$C$4:$C$‌​19,$C$4:$C$19>=E$4:E‌​$19)),true)-countif(‌​E4:E19,"N/A")
I had to go back into the data and change the blank cells to "N/A" to make it work, but it works!!

Resources