Count number of times text is repeated in a spreadsheet (excel) - excel-formula

I have a spreadsheet with this kind of data:
I would like to count the number of times the same text has appeared before in the spreadsheet. For Example if "Charlie" has been mentioned three times, the first time it appears it will show "1", the second time "2", the third time "3" and so on.
The end result I am looking for would be something like this:

You'll need to combine several combinations of Countif and add them all up
In the result sheet:
A1 and copied down:
=COUNTIF(Data!$A$1:A1,Data!A1)
B1 and copied down:
=COUNTIF(Data!$A$1:$A$7,Data!B1)+COUNTIF(Data!$B$1:B1,Data!B1)
C1 and copied down:
=COUNTIF(Data!$A$1:$A$7,Data!C1)+COUNTIF(Data!$B$1:$B$7,Data!C1)+COUNTIF(Data!$C$1:C1,Data!C1)

Related

Lookup using multiple columns

I have a sheet filled with data below (and in the image):
Now there's this other sheet where the user will only be inputting the column "Gender" and "Age" values and the excel formula should be fetching the associated factor. Please help me with one such formula.
For e.g. If the user puts Male and 23, the formula should return 3. say Male was entered in Cell D46 and 23 was entered in E46 of Sheet named "Sheet4" and the table shown above happens to be in "Sheet1"
Please advise.
Right, now I can visualize what you meant in your other comments in your previous question, it's a rather easy redo of our other formula.
Formula in F3:
=INDEX(C1:C13,MATCH(1,(ROW(C1:C13)>=MATCH(F1,A1:A13,0))*(B1:B13=F2),0))
Entered through CtrlShiftEnter
Notice that these formulas will return a wrong result if, lets say you extend till females age of 29, and you will search for male, it will still return the value for female. It will however not fail when your searchcriteria would be always right.
You could prevent this in this case (because you only really have one criteria and a fixed range with this formula in F3:
=IFERROR(IF(F1="Male",INDEX(C2:C9,MATCH(F2,B2:B9,0)),INDEX(C10:C13,MATCH(F2,B10:B13,0))),"No result")
Just enter normally. What it does is it checks what gender type is chosen and choses it's lookup index accordingly.
Another option would be to use SUMPRODUCT() like so :
=IF(F1="Male",SUMPRODUCT((B2:B9=F2)*(C2:C9)),SUMPRODUCT((B10:B13=F2)*(C10:C13)))
Also, if you are curious what formulas do and want to learn from them, a great way to do so is using the build-in formula evaluate function, that will show you step by step what the formula will calculate.
EDIT
Tried, as per your comment, to break it down for you so you understand what is going on:
For situations like this, I've learned a good trick how to fill in the blank cells:
Select all cells in the column with the "gender" values.
Goto Special, Blanks. (You active cell should be A3)
In the formula bar, type =A2. (I believe that A2 contains the word "Male")
Press Ctrl+ENTER (don't forget the Control key for filling all selected cells)
As a result, A3 will be copied from A2 and contain the word "Male", A4 will be copied from A3 and will now also contain the word "Male", ...
Further: this stops at the first occurence of the word "Female" (this cell is not selected), and for the later cells, the copying happens in the same way as before.
From here, it should be far easier to achieve your goal.

Return Dates of Three Consecutive Values in a Row

I have a data file and I need to return the dates of when the value (MaxT) is greater than or equal to 30 (>=30) for 3 consecutive days.
Data File:
Date, MaxT
1872-03-01,31
1872-03-02,29
1872-03-03,37
1872-03-04,40
1872-03-05,22
1872-03-06,9
1872-03-07,28
1872-03-08,31
1872-03-09,35
1872-03-10,37
1872-03-11,44
1872-03-12,29
1872-03-13,35
1872-03-14,48
1872-03-15,33
1872-03-16,31
1872-03-17,38
1872-03-18,31
1872-03-19,42
1872-03-20,20
1872-03-21,24
1872-03-22,31
I have attempted to figure this out using the following code but, I do not think I'm even in the ballpark...
Attempted Code:
=SUMPRODUCT(--(FREQUENCY(IF(B2:B23>=30,ROW(B2:B23)),IF(B2:B23>=30,ROW(B2:B23)))=3))
I'm assuming that your data file consists of 2 columns Date and Max T. If they are delimited by commas, you need to split them to 2 different columns using Text to columns delimited by commas ,.
The Date should be in Column A and Max T in Column B.
Enter the below formula in cellC2 and drag down,
=IF(AND(B2>=30,B3>=30,B4>=30),"Consecutive Range","")
The starting of the consecutive range of values greater than 30 will be shown in the output as above. You could then use a filter of some other excel function like Index-Match to get the corresponding dates. Hope this helps.
Alright, I got it to work, but I'm not entirely sure how you would make it work without separating the formula into multiple cells.
One potential solution would be to write some of the formulas into a sheet that's in the background, place the final part of the formula in the front sheet and have it reference the "hidden" bits of the formula.
First, I wrote the data in columns... "Date" in Column A, "MaxT" in Column B.
The first part of the formula is written in cell D2:
=IF(B2>=30,B2,"")
The next part of the formula is written in cell E2:
=COUNT(D2:D4)
The last part of the formula is written in cell F2:
=IF(E2=3,A2&","&A3&","&A4,"")
The result of this formula, in column F, there are 7 cells that have three dates written in them, separated by a comma.
Note that you can make any character or string of text separate the three displayed dates by replacing the commas that are in-between the ampersand, quote text:
(&","&) can become (&"anything you want"&)
From here, auto-fill the formulas to the relevant cells.
EDIT:
One way to shorten the code is to add the COUNT formula into the last IF statement like this:
=IF(COUNT(D2:D4)=3,A9&","&A10&","&A11,"")
I do still think that the first IF statement will need to be separate from the rest of the formula, though.
EDIT #2
Here is the code in one single cell:
=IF(AND(B2>=30,B3>=30,B4>=30), A2&","&A3&","&A4,"")
Which will display three dates that are located within Column A, current row & the next two rows below it.
This code still produces 7 lines of results with the data that you've provided.

Excel complicated count function

I have kind of a complicated count I can't seem to figure out. Basically I have a table that looks similar to this image:
Now what I need to do is:
Tally the number of 1's if the category = "Anon" in one cell, then count the number of 2's and 3's in separate cells all if the category = "Anon".
Wash/Rinse/Repeat for if it's "Watterson" and "Davis".
Is there any way I can count the occurrences of 1|2|3 and have it separated by category like this?
Sorry, kind of an Excel noob here. I didn't think pivot tables would be correct though (especially because they want the dates to be columns, plus I couldn't figure out how to insert a conditional). Any pointers in the right direction would be appreciated.
Let's suppose that your screenshot shows cells A1:I6.
Then ...
Add column headings "1", "2", "3" in cells J1:L1
Put the formula =COUNTIF($C2:$I2,J$1) into J2 and copy it across and down
Set up a list of unique Categories (Anon, Watterson etc) starting in A10
Add headings in row 9 like "Category", "Tally of 1s", "Tally of 2s", "Tally of 3s"
Put the formula =SUMIF($B$2:$B$6,$A10,J$2:J$6) into B10 and copy it across and down
My guess is that someone cleverer than I could construct a sumproduct formula for B10 that works without the need for the helper columns J:L.
[Edit] Using Maki's sumproduct formula in my structure, you can scrap helper values in cols J:I and put this into B10 -- =SUMPRODUCT(($B$2:$B$6=$A10)*($C$2:$I$6=B$9))
assuming that you start from cell A1,
=SUMPRODUCT((list name to search for)*(value to search in the data area))
=SUMPRODUCT(($B$2:$B$6="Anon")*($C$2:$I$6=1))
=SUMPRODUCT(($B$2:$B$6="Anon")*($C$2:$I$6=2))
...
=SUMPRODUCT(($B$2:$B$6="Watterson")*($C$2:$I$6=1))
...etc.

Using VLOOKUP for Multiple Parts of a Cell

I am trying to create a decoding macro. I have different combinations of letters in each cell on one sheet. For example, in cell B2 I would have something like "ABC." On a different sheet I have a table that matches letters to numbers, so I want the output in the new cell to be "123" in that case. I know how to use VLOOKUP on an entire cell, but cannot figure out how to use it on individual parts and then concatenate the results back together in the new cell.
This is what I've figured out so far. I think I need INDIRECT as part of it so I can reference the cell, but I cannot figure out how to look up the different portions of the cell. I do not want to create new columns to split the letter combinations up if possible.
=IFERROR(VLOOKUP("not sure??",'Conversion Table'!A4:B19,2,FALSE),"")
Thanks!
I'm assuming your cell B2 is limited to 3 chars only, and it's the same everywhere. In this case, you can do:
=CONCATENATE(VLOOKUP(MID(B2,1,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,2,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,3,1),'Conversion Table'!$A$4:$B$19,2,0))
If you have more chars, only add them using concatenate and select them one by one using MID.
Edit - locked the lookup table.
I think what you may be looking for is this:
A B C D
1 =""
2 ABC =IFERROR(VLOOKUP( =D1&C2
B2,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
3 XYZ =IFERROR(VLOOKUP( =D2&C3
B3,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
4 PQR =IFERROR(VLOOKUP( =D3&C4
B4,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
5 DEF =IFERROR(VLOOKUP( =D4&C5
B5,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
The "Final Answer" appears in cell D5

Google Spreadsheets: how to display the amount of cells that contain specific multiple text and numbers

I'm trying to create a spreadsheet in Google Spreadsheets to use for score keeping in a pool league and have run into a problem.
I have two sheets in the spreadsheet. The first is called "Actual Scoresheet" and contains scores from the game. The second sheet is called "Player Stats" and contains stats from each player during the game.
In the "Actual Scoresheet", I have a range of cells (for example F37:T37) where the scores from each game are entered. There are 4 different possibilities for a win that can be entered in any of the cells in this range. These possibilities are "14", "BR", "TR", "WZ".
In the "Player Stats", I have a cell that I want to show the total amount of wins in the range of cells contained in "Actual Scoresheet".
I tried this formula
=COUNTIFS('Actual Scoresheet'!F37:T37, "14", 'Actual Scoresheet'!F37:T37, "BR", 'Actual Scoresheet'!F37:T37, "WZ", 'Actual Scoresheet'!F37:T37, "TR")
but it is only returning a value of 0 even though cells F37:T37 contain 2 TR's and 2 14's, which should return a value of 4.
Can anyone help me figure out what I'm doing wrong? Thanks
Given tag, Excel version:
=SUM(COUNTIF('Actual Scoresheet'!F37:T37,{14,"BR","TR","WZ"}))
or for a locale with; as the separator:
=SUM(COUNTIF('Actual Scoresheet'!F37:T37;{14;"BR";"TR";"WZ"}))
Again both are to be entered as an array formula, in Excel with Ctrl+Shift+Enter.
CSE entry not necessary, see the maestro's comment below.
14 may be either a number or a string.
As per +Tim Williams' comment, you essentially have an OR condition rather than an AND; so you can sum individual COUNTIF()s, or a bit shorter:
=ArrayFormula(SUM(COUNTIF('Actual Scoresheet'!F37:T37,{"14";"BR";"TR";"WZ"})))

Resources