I have a spreadsheet of orders of fruits.
The varieties of fruits contained in a given order are all written in the same cell, coma separated.
If I want to get the number of orders that include bananas, I do the following
=COUNTIFS('Order List'!C:C,F$1,'Order List'!AG:AG,"*Banana*")
If I want to get the number of orders that include oranges, I do the following
=COUNTIFS('Order List'!C:C,F$1,'Order List'!AG:AG,"*Orange*")
This works.
Now I want to know how many orders include bananas and/or oranges.
The sum of the 2 previous results does not work, since any order including both Oranges and Bananas would be counted twice.
I could not find a way to write the regular expression that matches the case where both appears (to subtract the intersection), because 1) there is no ordering in the list, so banana could appear before or after orange and 2) because the number of intersections grows too fast when more items are in the list.
It seems a simple problem but I haven't figured out how to do this, your help is very much appreciated !
You may try:
Formula in C1:
=SUMPRODUCT(--(MMULT(IFERROR(FIND(TRANSPOSE(B1:B2),A1:A5),0),MOD(ROW(A1:INDEX(A:A,COUNTA(B1:B2))),1)+1)>0))
I think you'll need to CSE-enter this pre-Excel365.
You can apply a trick. First SUM both individual result then substract result counting contains both. Like below-
=COUNTIF(B3:B6,"*Banana*")+COUNTIF(B3:B6,"*Orange*")-COUNTIFS(B3:B6,"*Banana*",B3:B6,"*Orange*")
Related
I have two classes (ABC and XYZ) and some students which have taken test in these classes. However, due to personal reason, a few students couldn't take several of the exams. I want to find the top 3 amounts of test not taken and top 3 names of the students that haven't taken the most exams. Below is an illustration of what I'm trying to do:
In cell F3, I've written the following code to get the top 3 amount of test not taken:
=LARGE(COUNTIFS(C:C,"="&"",B:B,UNIQUE(FILTER(OFFSET($B$2,0,0,COUNTA(B:B)-1,1),OFFSET($A$2,0,0,COUNTA(A:A)-1,1)=$F$2))),ROWS(B$2:B2))
My goal is to now list the top 3 non test taker names. I've tried a variation of the above code but can't seem to make it work. I have excel version 2209 if this helps. Thank you in advanced!
Try:
Formula in E2:
=LET(x,UNIQUE(FILTER(B:B,(A:A=F1)*(C:C=""))),SORTBY(x,MAP(x,LAMBDA(y,COUNTIFS(A:A,F1,B:B,y,C:C,""))),-1))
Or, for both names and count:
=LET(x,UNIQUE(FILTER(B:B,(A:A=F1)*(C:C=""))),SORT(HSTACK(x,MAP(x,LAMBDA(y,COUNTIFS(A:A,F1,B:B,y,C:C,"")))),2,-1))
You can use the following in E2 cell:
=TAKE(SORT(HSTACK(UNIQUE(B2:B14),
COUNTIFS(B2:B14, UNIQUE(B2:B14), C2:C14, "")),2,-1),3,1)
or using LET to avoid repetition and define the inputs first:
=LET(x, B2:B14,y, C2:C14,
TAKE(SORT(HSTACK(UNIQUE(x),COUNTIFS(x, UNIQUE(x),y,"")),2,-1),3,1))
Here is the output:
COUNTIFS counts the total number of blanks for unique names, the rest is just to accommodate the result to the output needs, i.e. sorting via SORT, pick the first three rows and only select names via TAKE.
If you need the result for a specific class, you can add an additional condition to COUNTIFS as follow or using a reference. For example for ABC class:
=TAKE(SORT(HSTACK(UNIQUE(B2:B14),
COUNTIFS(B2:B14, UNIQUE(B2:B14),A1:A14, "ABC", C2:C14,"")),2),3,1)
I've got a column showing an outcome (positive/negative), and the other column contains the reasons for that outcome in text format, looking something like this:
https://docs.google.com/spreadsheets/d/1bgZnZBGY_0iksANrsixRXRSNz0l9REYmJC29ZmygNjs/edit?usp=sharing
What I want to do is to group the reasons together and find the number of outcomes that contain at least one of those "reasons", as seen in columns G and H.
I've tried using =sum(countifs(C3:C9,{"Understands responsibility","Takes instruction well","Looks forward to work"})) for the first grouping, for example, but it only gives me the count for "Understands responsibility", but not the rest.
Using countif alone repeats the count of the outcome if multiple "reasons" in the groupings are under the outcome. (i.e. there's a double count if "Understands responsibility" and "Looks forward to work" are in the same cell for reasons)
Help would be appreciated, many thanks.
Try this in H3.. needs to be 'Control-Shift-Enter'ed:
=SUM(1*(MMULT(1*(TRANSPOSE(ROW(E3:E5))>0),1*ISNUMBER(SEARCH(E3:E5,TRANSPOSE(C3:C9))))>0))
This results in a "distinct count" per row. It can take a variable number of responses and reason groups; you can change 'E3:E5' in the 2 spots to point to your other groups.
I'm trying to rank values and have managed to work out how to sort ties. My data looks at the total number of entries, ranks based on that and if there is a tie it looks to the next column of values to sort them out. However, I have two classes (East and West I've called them) of data within my dataset and want to rank them both separately (but stick to the rules above). So, if I had seven entries, 3 of them West and 4 of the East, I want West to have ranking 1,2,3 based on all the values that lie in that subset and East would have ranking 1,2,3,4. Can you explain what your formula is doing so I can understand how to apply your answer better in the future.
Effectively I'm asking what formula needs to go in achieve my result.
Cheers
Paul
There are a few related ways to do this, most involving SUMPRODUCT. If you don't like the solution below and would like to research other ways/explanations, try searching for "rankif".
The function looks up the Class and Value columns and, for every value in those columns, returns a TRUE or 1 if the current Class is a match AND if its Value is larger than the current Value, False or 0 if otherwise. The SUM adds up all these 1s, and the 1+ is for decoration. Remember to enter as an array formula using Ctrl+Shift+Enter before dragging down.
I used the array formula and SUM above to explain, but the following also works and might even be faster since it's not an array formula. It's the same idea, except we hijack SUMPRODUCT's ability to spit out a single value from an array.
=1+SUMPRODUCT(($A$2:$A$8=A2)*($B$2:$B$8>B2))
EDIT
To extend the rank-if, you could add more subsets to rank by multiplying more conditions:
You can also easily add tiebreakers by adding another SUMPRODUCT to treat the ties as an additional subset:
The first SUMPRODUCT is the 'base rank', while the second SUMPRODUCT is tiebreaker #1.
I am looking for a method to match two excel tables.
I basically have two Systems, where the values do not exactly match only some IDs. The values in system 2 are usually 10-20% different from system 1.
Here is how the sheet looks like:
I tried to use vlookup on the IDs and then going hand-by-hand through the values if they match, by using the filter with the ID. However, this takes extremely long and is very cumbersome.
Any recommendation how to match these two tables, much more easily?
I really appreciate your replies!
If you look at a formula for G3 you would be involving D3:E3 and A:B (where A10:B10 are the matching values).
When someone states that they are looking for a percentage, it is helpful to know "a percentage of what...?". You receive a different result if the calculation is ABS(12 - 15)/15 instead of ABS(12 - 15)/12. One may within tolerance and the other may not.
In any event, the formula for G3 would be something like,
=ABS(E3-VLOOKUP(D3,A:B, 2, FALSE))/E3
... or,
=ABS(E3-VLOOKUP(D3,A:B, 2, FALSE))/VLOOKUP(D3,A:B, 2, FALSE)
That produces a result of 0.25% or 0.20% depending on how you calculate the percentage. You could wrap that in an IF statement for a YES/NO text result or use a custom number format like [Color3][>0.2]\NO;;[Color10]\Y\E\S;# which will show a red NO for values greater than 20% and a green YES for values between 0 and 20%. Negative values do not have to be accounted for as the ABS removes them from consideration.
I've only reproduced a minimum of your sample data for demonstration purposes but perhaps you can get an idea on how to proceed from that.
I'm doing like a bit of a competition for my students in which they have a weekly test they have to complete and submit. The grade is stored in an excel column next to their names.
Following instructions i found, i was able to create a full working general TOP3 with the Average of the tests' grade and when i get to the TOP5 for the grades of the last submitted test, i get a three-way tie.
I use the LARGE function to find the top grades and the combination of the INDEX and MATCH functions to find and display the name associated to that mark.
(Something like this =INDEX($A$1:$A$29;MATCH(M12;$F$1:$F$29;0))
The problem is that the function compares the grade on it's left to find that value in the range of grades and then returns the corresponding name associated to that row; so, it returns the same name for the three grades.
I tried using an IF function to exclude the first-result-cell from the array in which the formula is looking so that when it finds a match it will be different from the previous one, but i have not manage to work it out...
You need to use a pivot table and filter the results to the top 3. A pivot table will display the ties.
Here is a link that #Jeeped gave which basically solves the problem!
Thank you all for commenting!
Multiple Ranked Returns from INDEX(…) with Duplicate Values:
http://tinyurl.com/naavhgf