Excel formula for counting combinations of checked boxes - google-sheets

I need help with a formula that counts unique combination of events from a checkbox form. Users check how many times they completed a task X, Y or Z. The program counts how many events were logged (under '#') and then the counts the unique combination of events and spits out the combo count (under 'Combinations').
For the sake of clarification, I'll refer to each category by its name and each numbered checkbox as X_1, X_2, etc.
Here are the design criteria:
Count unique combinations between two separate events (e.g. [X_1,Y_1])
Once a single instance of an event is counted, you cannot use it again (e.g. X_1 cannot be paired up twice => [X_1,Y_1], [X_1,Y_2])
However, you can pair multiple instances of the same event to other unique events (e.g. [X_1,Y_1], [X_2,Y_2], [X_3,Z_1])
Combinations cannot be made between multiple instances of the same event (i.e. [X_1,X_2] is not valid)
So in the example above, the correct number of combinations should be 3 (i.e. three unique combos of events with each individual event counted only once). I've built two formulas. The first (H2) uses INT and COUNTIF functions to count number of checked boxes column-by-column. It yields an incorrect answer of two.
=INT(COUNTIF(C2:C4,true)/2)+INT(COUNTIF(D2:D4,true)/2)+INT(COUNTIF(E2:E4,true)/2)+INT(COUNTIF(F2:F4,true)/2)+INT(COUNTIF(G2:G4,true)/2)
The second (H3) uses the INT and SUM function to estimate a total from the data container in column A. It yields an incorrect answer of 4.
=INT(SUM($A$2:$A$18)/2)
I believe the MOD function may work well in addition to the COUNTIF function. Go column-by-column, count unique combinations, and any remainder will count towards finding an odd event in the next column.
Any help is appreciated. Thank you for reading.

Does this formula work, in H5? I think it gives the correct number of possible pairings.
=MIN((MAX(1,C10)+MAX(1,D10)+MAX(1,E10)+MAX(1,F10)+MAX(1,G10) - COUNT(C10:G10)),
INT(COUNTIF(C2:G9,TRUE)/2))
It uses a helper row, which totals the number of different users for each possible attempt, in cells C10:G10. This only needs to be entered once.
The formula in H10 is:
=COUNTIF(C2:C9,true)
and it needs to be dragged across under all of the checkboxes, ie in H10 to G10.
Here is my result.
It would be possible to eliminate the helper row, doing the totals below the checkboxes, but it would make the formula very messy I think.

Related

how to get UNIQUE value in tableau?

so I am trying to get the number of data points that have passed or failed based on their ID. However tableau only has COUNTD which does a distinct count and not a UNIQUE count (trust me this will out put two different numbers). Is there a function or formula to get the unique IDs?
One attempt I'm trying to do is count how many times an ID appears and only counting the ones that appeared once, but that is appearing more difficult than I thought. Any other suggestions would be helpful.
I've also tried an LOD function of IF SUM{FIXED([ID]):COUNT([ID])} but that didn't work out either.

Find a value in an array and return a range result - GSheets

Introduction
I am managing an event where I have volunteers to assign to some tasks over a few days.
Here is the link to a simplified version of my sheet: https://docs.google.com/spreadsheets/d/18_zRRmmT85pWc9rW8oS619YiTnxMzEEdJAS9Ayut4RQ/edit?usp=sharing
I need two views to gently handle the event:
Full volunteers list, with assigned tasks, in order to ensure that each of them are assigned a task and to inform them about their assigned task when they arrive at the event (refer to the Volunteers tab),
Tasks planning, with associated volunteers so I can keep track of the presence of the volunteers at the time they should be working (refer to the Activity X tabs)
Problem
Now I will manually fill in the activity tabs with my volunteers and I need to have the Assignation (expected) column in Volunteers tab filled automatically (see the provided examples).
Hence the title: I need to find, in each Activity tab, the name of the assigned volunteers (value) and to retrieve which tasks with date and hour he has been assigned to (range result).
Constrains
The Volunteers tab already exists and is used for several purposes. Therefore it cannot be fully generated from the other tabs, only the Assignation column must be filled automatically,
A single volunteer can have several assignation for the same activity (as long as it is not on the same time slot, so he will not appear twice in the same column),
A single volunteer can have several assignations through several activities,
Volunteers list in Activity X tabs would be hard to keep sorted as we fill the planning
Approaches already tried
LOOKUP family functions
LOOKUP: works only with sorted values, which is merely impossible to maintain by hand as we fill the tables.
HLOOKUP: According to the documentation and admitting we cheat a bit in incorporating the recap in the range, it provides the expected result but only for the first row of the range:
=HLOOKUP(A2, act1_volunteers,ROWS(act1_volunteers), FALSE)
VLOOKUP: Would not allow to retrieve the summary rows that I need to display on first tab.
HLOOKUP in ARRAYFORMULA
I have hoped that function would let me perform a kind of for each row in range action, but it provides the same result of the previous approach.
=ARRAYFORMULA(HLOOKUP(A2, act1_volunteers,ROWS(act1_volunteers), FALSE))
INDEX & MATCH
MATCH applies only on 1-dimension (either a row or a column, but not a range), and cannot be applied with ARRAYFORMULA to extend.
I have come to an end about my ideas, I was quite surprised to struggle to find such a function. I really feel the expected views are needed for the different managers of the event, but I could envisage to reform the tables if that could ease the process.
You can try this formula below:
=TEXTJOIN(" / ", TRUE, FILTER(SPLIT('Activity 2'!$L$4, "|"), IF(REGEXMATCH(SPLIT('Activity 2'!$L$4, "|"), A2)=TRUE, "TRUE")))
Use this to match your name to the concatenated task list. You should paste this on the first cell and later drag it down the column.
A new sheet has been created and this is how the end result looks like:
Reference
TEXTJOIN;
FILTER;
SPLIT;
IF;
REGEXMATCH.

Google Sheets Count Unique Dates based upon a criteria in different columns

I am trying to find a formula that will give me the count of unique dates a persons' name appears in one of two different columns and/or both columns.
I have a set of data where a person's name may show up in a "driver" column or a "helper" column, multiple times over the course of one day. Throughout the day some drivers might also be helpers and some days a driver may come in for duty but only as a helper. Basically all drivers can be helpers, but not all helpers can be drivers.
I've attached a link to a sample sheet for more clarity.
https://docs.google.com/spreadsheets/d/1GqNa1hrViX4B6mkL3wWcqEsy87gmdw77DhkhIaswLyI/edit?usp=sharing
I've created a REPORTS tab with a SORT(UNIQUE(FLATTEN)) Formula to give me a list of the names that appear in the DATA Tab.
I'm looking for a way to count the unique dates a name from the name (Column A of the REPORTS Tab) appears in either of the two columns (Column B and/or C of the DATA Tab) to determine the total number of days worked so I can calculate the total number of days off over the range queried.
I've tried several iterations of countif, countunique, and countuniqueifs but cannot seem to find a way to return the correct values.
Any advice on how to make this work would be appreciated.
I think if you put this formula in cell b7 you'll be set. You can drag it down.
=Counta(Unique(filter(DATA!A:A,(DATA!C:C=A7)+(DATA!B:B=A7))))
Here's a working version of your file.
For anyone interested, Google Sheets' Filter function differs slightly from Excel's Filter function because Sheets attempts to make it easier for users to apply multiple conditions by simply separating each parameter with a comma. Example: =filter(A:A,A:A<>"",B:B<>"bad result") will provide different results between the Sheets and Excel.
Excel Filter requires users to specify multiple conditions within parenthesis and denote each criterion be flagged with an OR condition with a + else an AND condition with a multiplication sign *. While this can appear daunting and bizarre to multiply arrays that have text in it, it allows for more flexibility.
To Google's credit, if one follows the required Excel Syntax (as I did in this answer) then the functions will behave the same.
delete what you got and use:
=QUERY(QUERY(UNIQUE({DATA!A:B; DATA!A:A, DATA!C:C}),
"select Col2,count(Col1),"&D2&"-count(Col2)
where Col2 is not null
group by Col2"),
"offset 1", 0)

Google Spreadsheets: Use row of nth occurrence of value for other calculations?

I am using a combination of Google Forms and Google Spreadsheets for data entry and interpretation for scouting in a robotics competition (FRC). The user fills out a form for each match with the data from 6 different teams. That data is put into a spreadsheet by the form, and the sheet of data is used by other sheets for interpretation, and it outputs different stats.
One of the sheets is designed to show the progression of the team's stats over the course of their 9-10 matches. I want it to show the values for a certain stat in the same order as the matches that they played (Match 1: 10 points; Match 2: 15 points; etc.). The problem is that there are upwards of 40 teams, so teams don't play back-to-back. I am trying to create a function that searches for the nth occurrence, by row, in the 6 columns that contain team numbers. That function would then use that row to return a value for a stat by that team from that match.
My spreadsheet is here. The sheet of raw data is called "Games", and the sheet containing the progression data is called "Over Time". Within the "Games" sheet, each line is a match, and there is data for each of the 6 teams in each line. Each team gets a line on the "Over Time" sheet, and each stat would take up about 10 columns.
The function would search for the nth time (as specified by the number in row 2) that the team number (as specified in column A) occurs. It would then search that row number for the team number and return the value in the column specified by the function (eg. If the team number occurs in column C, return the value in column E of the same row.). In the sheet "Averages", I used mainly SUMIF and COUNTIF functions to return averages for each stat, but I can't figure out how to use the array functions that would be necessary for the first step of this function. I would prefer to avoid using hidden columns and rows, as that just gets messy, so it would be great if the entire function is in one cell. I would also prefer it to be a function, as opposed to a script.
This solution uses one function per row (not one function for the entire table). In 'Over Time'!B3:
=ArrayFormula(SPLIT(CONCATENATE(REPT('Games'!E$2:BW&CHAR(9);('Games'!C$2:BU=A3)*(MOD(COLUMN('Games'!C$2:BU$2);14)=3)));CHAR(9)))
which can be filled down to B8.
If it is absolutely necessary to have one formula for the entire table, then I'm sure it could be done, but it will be horribly complex. Further, as it is, these "concatenate then split" type formulae (which you need to resort to when the data isn't nicely vertical) are quite inefficient, depending on how big your source data gets. That may not be an issue in your case, but for big source data sets, I would prefer a custom function for performanc ein this case.

Google Spreadsheet: Query String and Numeric (Involving math formula)

Sorry about the imprecise title. Allow me to elaborate. I'm currently in the process of making 'Order' sheets for the small retailer i work for. Some items are easy to count due to low inventory while other items are abundant and difficult to count but easy to gauge whether we ought to order them.
When an employee takes a store count, the on-hand number they put down is contrasted with a minimum. The minimum is our lower threshold. The minimum is subtracted by the input quantity and a formula produces a third column, "Order". If the number in the order column is < 0 then a query function on a separate sheet will copy the entire row. To be clear, there are three columns, "On Hand", "Minimum", "Order", with the "Order" column containing the following mathematical formula:
="Minimum" - "On Hand"
[Cells are specified so that it would look more like "=B2-A2".]
However, I'd also like to include the ability for employees to put a simple 'x' in the count spot, signifying that we need to order the product without having to count every single instance of the item. I'd still like to include the ability for them to enter a number if they so choose. I'd like for them to be able either the number or the 'x' in the same column. I'm currently using the following query function:
=QUERY('String(Fail)'!A:D;"select * where A contains 'x' or C > 0")
[The above is from a sheet I'm experimenting with. I will provide a link below in case you're more hands-on.]
The issue arises when the formula in the "order" column outputs any sort of number. If the formula is functional, no row marked with an 'x' is copied to the new page via the query command. If any row produces a numeric, no 'x' rows are copied over at all. I've experimented a bit but am at a loss as to where to go next.
The sheet I'm currently experimenting with is linked below. If you'd like any additional information I'd be happy to provide it. I'm relatively new to all of this so excuse my stupidity. I do recognize that I could very likely make a script for this but am not well versed in scripting with Google Apps and enjoy the immediate benefits of the query function.
Any help is welcome. Thank you.
Experimental Spreadsheet
All the values in a column need to be of the same type in order to be evaluated by QUERY. The mix of 'x' and numbers is confusing things.
If you use the Format menu to ensure all the values in column A are Plain Text, then your Query will work. (Formatting a numeric value as plain text does not stop it from working in a numeric calculation, so your column C survives.) Here's a screenshot of your query, after doing that formatting:
Based on your specification, your query needs to have the comparison to zero reversed, like this:
=QUERY('String(Fail)'!A:D;"select * where A contains 'x' or C < 0")
^^^

Resources