Optimal to lookup and display column/row names from a table of binary data - excel

Job Coach ConsumerName Monthly General Goals
Anna Joe 0 0 0
Sam John 0 0 0
Veron Jane 0 0 0
Bill Jack 1 1 1
Anna Jill 1 1 1
Jim 0 0 0
Bill Jiang 1 1 1
Jolly 0 1 1
Sam Jiant 0 0 0
Jap 0 1 1
Joule 1 1 1
Aardvark 0 1 0
Drake Darding 0 0 0
Hello, as you can see above I have two columns of strings; one column is "job coach" the other is "consumer name". There are three columns of 1's and 0's; monthly, general, and goals.
I'm trying to find the specific pattern of 1's and 0's in each of the rows, and to report it. For instance, the data says:
Consumer Jolly still has a a monthly which needs to be completed;
Consumer Aardvark still has a monthly which needs to be completed;
Consumer Aardvark still has a monthly and a goals which needs to be completed.
Lookup doesn't really work, because it only will return the first instance of the corresponding variable and not additionally instances.
I've tried a index function like this:
{=INDEX($C$2:$E$14,SMALL(IF($C$2:$C$14=0,ROW($C$2:$C$14)),ROW(1:1)),3)}
But that only would look up for a single column at a time, which makes the report rather cumbersome. I'm open to doing a loop in excel without formulas, however its not a simple looping formula, because I'm trying to look at each cell and to output the specific column name.
Any thoughts on how to best do it?

It's not exactly clear what the condition you want to check is, but if you want to check for a specific given pattern and return the customer name you can use this adjusted formula:
=INDEX($B$2:$B$14,SMALL(IF($C$2:$C$14&$D$2:$D$14&$E$2:$E$14="010",ROW($C$2:$C$14)-1),ROW(1:1)),1)
In your formula you checked only the first binary column and returned the last. You also had a mistake of returning the row number and not the index in the list which is row-1 in your case.
So notice:
The INDEX returns values from column B.
The IF checks a pattern of C&D&E equals a pattern like 010 which can be changed or set to a reference.
Then return the ROW()-1 in case your list starts at row 2, to return the index in the data and not the actual row.

Related

How do I count the number of cells in a column against criteria in another column

I need help creating a formula to count number of unique delivery stops each day. The table below is similar to my actual data.
Name
Address
Sun
Mon
Tues
Wed
Bob
1 Main St
1
0
1
2
George
3 Main St
3
0
1
2
Tom
4 Main St
4
0
1
2
Harry
1 Main St
0
0
1
2
Randy
1 Main St
0
0
4
2
Homer
5 Main St
2
0
1
2
Bill
10 Main St
3
0
1
2
Jim
1 Main St
1
0
1
2
Joe
2 Main St
1
0
1
2
For instance, "1 Main St" is marked 4 times on the chart, but on Sunday there were 2 deliveries but only 1 actual stop at that location.
How would I go about calculating that based with a formula? I originally tried a ```=SUMPRODUCT```` but it wasn't calculating correctly, it would count each delivery stop, I'm not sure how to make it not count 0's and to combine multiple deliveries to the same address as a single delivery.
My last formula was "=SUMPRODUCT((COUNTIF($D$6:$D$96,$D$6:$D$96)=1)*$J$8:$J$98)
Where Column D is the addresses and J starts the delivery counts on Sunday.
Thanks
EDIT
Sorry, I wasn't clear with my question: I need a way to count the number of stops made per day (so if an address has multiple deliveries to different people, it's just counted as a single stop and 0's are skipped). Using Excel 2013
After many, many attempts, here it is...
Answer:
=SUM(IF(LEN(UNIQUE(FILTER(B2:B10;C2:C10>0;0);FALSE;FALSE))>1;1;0))
Where B2 is the first address, C2 is the first row under sunday.
This will give you unique delivery locations. So, if you visit the same place multiple times in one day, it is still counted as 1. If 0, it is counted as 0.
Your question was VERY unclear. Next time around, please tell us what you want the result to be.
This answer will give 6 for Sunday. If there are no deliveries, it will be zero. This last point took me hours to solve. COUNTIF won't work on single cells, only arrays. COUNT only works on numbers, COUNTA... Well, apparently COUNTA counts empty arrays (like if FILTER returns nothing). So I had to get the length (>1 for some reason). If it was greater than 1 in length, add 1, otherwise 0. And finally SUM it all.
Like I said, this is to calculate deliveries on Sunday, so this formula will be repeated for the other days.
Hope you like it! ^_^

excel : determine if a combination of several cells exists and output result

Considering the following data :
sheet1 (customers)
A
0 customer_name
1 john
2 kevin
3 mickael
sheet2 (products)
A
0 product_name
1 book
2 ball
3 game
sheet3 (orders)
A B
0 customer_name product_name
1 john book
2 john game
3 mickael ball
I would like to know for each combination of customer and product if an order has been ordered and display it in the sheet1 to get something like that :
sheet1 (customers updated )
A B C D
0 customer_name book ball game
1 john 1 0 1
2 kevin 0 0 0
3 mickael 0 1 0
I know how to do that with "code" (by doing a macro in vba or a small exe in c# that will update the file), but I want to do it (if its possible) by just setting a formula inside my sheet (fyi, I can put the 3 inputs in the same sheet if needed, that's not a constraint
Updated :
with the previous configuration described, I have put the following formula in sheet1 B2 : =COUNTIFS(Sheet3!$A:$A;$A2;Sheet3!$B:$B;B$2), and when running the formula and extending it to every cell in my sheet I am getting everywhere the value #NAME? (I've translated if from french so I am not sure if its the right error in english). I think where I am making a mistake is that I am not using sheet2, how can I say first to "do all the combinations possible of customers insheet1 and products in sheet2 and look for those combinations in sheet3, knowing that I am in sheet1 and that I want to display the result like aking before?
Use COUNTIFS:
=COUNTIFS(Sheet3!$A:$A,$A2,Sheet3!$B:$B,B$1)

Counting digit in column based on subject

I am just using formulas in excel and was wondering how you could count all the 0s until a 1 is reached, and then start the process over again, based on subject number. If this is not possible simply with formulas, how could I write a VBA code for this?
Right now I am trying to use,
=IF(OR(F4=0,F3=1),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
which I input in I3 and I change the COUNTIFS($A$#:A#, $A$#...) part for each subject number.
This seems to work with the exception of the last grouping, as it won't output a number before the next subject.
Example Data:
subid yes number_yes(output)
1 0
1 0
1 0 3
1 1
1 0 1
1 1
1 0
2 0
2 0 2
2 1
2 0
2 0
3
etc.
A blank cell is numerically zero and that is one of your accepted conditions. Differentiate between blanks and zero values.
=IF(and(f4<>"", OR(F4=0,F3=1)),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
Based on #Jeeped answer. If you use -SUMIF($A$2:A2,A3,$I$2:I2) instead of -SUM($I$2:I2) you don't need to adjust this part for each subject number. Just use the following formula in I3 and copy it down.
=IF(AND(F4<>"",OR(F4=0,F3=1)),"",COUNTIFS($A$2:A3,A3,$F$2:F3,0)-SUMIF($A$2:A2,A3,$I$2:I2))
Note that I also changed the second parameter in the COUNTIFS to A3.

Count occurrences of strings just once per row in Google Sheets

I have strings of spreadsheet data that need counting by 'type' but not instance.
A B C D
1 Lin 1 2 1
2 Tom 1 4 2
3 Sue 3 1 4
The correct sum of students assigned to teacher 1 is 3, not 4. That teacher 1 meets Lin in lessons B and D is irrelevant to the count.
I borrowed a formula which works in Excel but not in Google Sheets where I and others need to keep and manipulate the data.
F5=SUMPRODUCT(SIGN(COUNTIF(OFFSET(B$2:D$2, ROW($2:$4)-1, 0), E5)))
A B C D E
2 Lin 1 2 1
3 Tom 1 4 2
4 Sue 3 1 4
5 1 [exact string being searched for, ie a teacher name]
I don't know what is not being understood by Google Sheets in that formula. Does anyone know the correct expression to use, or a more efficient way to get the accurate count I need, without duplicates within rows inflating the count?
So this is the mmult way, which works by finding the row totals of students assigned to teacher 1 etc., then seeing how many of the totals are greater than 0.
=ArrayFormula(sum(--(mmult(n(B2:D4=E5),transpose(column(B2:D4)))>0)))
or
=ArrayFormula(sum(sign(mmult(n(B2:D4=E5),transpose(column(B2:D4))))))
Also works in Excel if entered as an array formula without the ArrayFormula wrapper.
A specific Google Sheets one can be quite short
=ArrayFormula(COUNTUNIQUE((B2:D4=E5)*row(B2:D4)))-1
counting the unique rows containing a match.
Note - I am subtracting 1 in the last formula above because I am assuming there is at least one zero (non-match) which should be ignored. This would fail in the extreme case where all students in all classes are assigned to the same teacher so you have a matrix (e.g.) of all 1's. This would be more theoretically correct:
=ArrayFormula(COUNTUNIQUE(if(B2:D4=E5,row(B2:D4),"")))

Finding the first ocurrence of a string below a given cell?

I've been trying to figure this out but I don't seem to get it right.
I have a spreadsheet with reports for different categories detailed by day (e.g. Toys, Drinks, General Store, Meat Store, Veggies, etc)
So, my spreadsheet looks something like this:
Toys
Day Me Wife Kid1 Kid2
9/28/13 0 0 0 0
10/1/13 29 3 0 0
10/2/13 0 7 34 25
10/4/13 0 0 0 0
AVERAGE 29 5 34 25
.
Drinks
Day Me Wife Kid1 Kid2
9/30/13 102 15 0 0
10/1/13 0 0 25 0
AVERAGE 102 20 0 0
etc etc
So the idea would be that I need to be able to find the Average row number for each different category, but I can't just look for it easily because in one category there might be expenses on more months (hence, more rows between the category's title and the average row). Any clues?
You can use
=ROW()+MATCH("AVERAGE",$A2:$A$1001,0)-1
The row reference to A2 is variable and you can paste it next to the category of interest. The row reference to A1001 is just far enough down in your spreadsheet to include all the data, and is fixed (but doesn't have to be).
You can use something like this perhaps:
=MATCH("AVERAGE",INDIRECT("A"&MATCH("Drinks",A:A,0)&":A1000"),0)+MATCH("Drinks",A:A,0)-1
MATCH("Drinks",A:A,0) returns the row number of Drinks
Which is used by INDIRECT and to convert into a range, from which MATCH then returns the number of rows after that header. Add to the number of rows before Drinks and remove 1 to get the actual row number.
Change the range of A1000 accordingly. I assumed a maximum of 1000 rows here.
Edit, if you have cross-sheet referencing, you need to change the formula to:
=MATCH("AVERAGE",INDIRECT("'Sheetname'!A"&MATCH("Drinks",'Sheetname'!A:A,0)&":A1000"),0)+MATCH("Drinks",'Sheetname'!A:A,0)-1
Assuming Sheetname is the name of that sheet.

Resources