Excel formula to find out how many times any of specified strings occurs in a given range - excel-formula

I have list of strings. Every string is in different row. I need to find out how many times any of specified strings occurs in a given range. Any of those strings can also occurs more than once. How could I solve this?enter image description here
I have tried the following formula =SUM(COUNTIF(AS11:AS21,{"aa",bb",cc"...}) (... in context mean the of possible strings).

First get a list of unique values with the Excel function "=UNIQUE"
With the Excel function "=COUNTIF" you can then Count the Values with help of the Unique Values
Formula in B2:
=UNIQUE(B2:B24)
Formulaa in E2
=COUNTIF(B2:B24;D2)

You don't want SUM(COUNTIF()), you just want the 'SUMIF()'.
In your sample image, if you put =COUNTIF(AS$11:AS$23, AQ11) you should get the count of "aa" instances. Just copy or fill that formula down and you should be all set.

Related

How to Sumproduct in Excel if partial string is found ignoring characters and specific cell values

I have a table similar to the one below in Excel and I want to calculate the sum of all the columns where "*weightl*" shows up in the variable name (first row).
However, if the value is 8888 or a character/string this should be ignored.
In this case, the result should be 64.
I tried using something like {+sumproduct(sumif(A1:F1,"\*weightl\*",A2:F4))}
However, this only returns 16 (the result of the first row). Also, I don't know how to exclude 8888 values.
Would be great if you could support with a formula to solve this!
Welcome to SO. For this you'll need an array formula:
=SUM(IF(IFERROR(SEARCH("weight",$A$1:$F$1),0)>0,IF($A$2:$F$4<>8888,$A$2:$F$4)))
NOTE: Because this in an array formula, it must be inserted with CTRL+ENTER+SHIFT instead of only
ENTER or it won't work!
How this works?
IF($A$2:$F$4<>8888,$A$2:$F$4) will return an array of only those cells which value are not equal to 8888
IF(IFERROR(SEARCH("weight",$A$1:$F$1),0)>0,IF($A$2:$F$4<>8888,$A$2:$F$4)) will check previous array of values, and it will search the word weight in row 1. If found, those values will be checked as ok. If not, those values will be ignored in the final sum.
As you can see in the image I posted, final result is 64.
Hope you can adapt this to your needs.

Excel: INDEX MATCH with partial number

I have a large table of 12 digit numbers and associated info
I have a small list of 10 and 11 digit numbers (the first and/or last digits were cut off) - I'm attempting to cross these two lists to identify the items on the small list
normally, I'd use an index match to bring the associated info out of the table into the list, but because today I have only partial numbers in my list, I can't get the formula to work
I've seen other examples here that search for partial text strings contained within a range, but I haven't been able to adapt those formulas to my data. wildcards don't seem to work with numbers.
Many thanks for your input, and apologies in advance if I failed to find an existing solution on the site.
To match partial numbers inside a number range, like you do with strings, you can use an array formula with INDEX/MATCH, by composing a temporary array that converts the numbers into strings.
Say column A is your 12 digit numbers column, and you want to match the sequence 1234567890 and retrieve the value from column B, This CSE formula works:
=INDEX($B$2:$B$9999, MATCH("*1234567890*",""&$A$2:$A$9999,0))
CtrlShiftEnter
Although you can use full columns A:A and B:B, this should be avoided as much as possible with array formulas, because they're slow. Full columns mean computing and operating arrays of more than a million entries, so avoid it. Also note the "expensive" conversion from numbers to strings (all numbers in the $A$2:$A$9999 are converted to strings here).
To use a cell reference, say D2, instead of the harcoded 1234567890, the formula should be used like this:
=INDEX($B$2:$B$9999,MATCH("*"&D2&"*",""&$A$2:$A$9999,0))

count unique values between defined range in column

I've got column which consist numbers of type 000.XX.XX
=COUNTIFS(temporary!$A1:$A200,">=000.11.35",temporary!$A1:$A200,"<=000.11.39")
this formula counts values between 000.11.35 and 000.11.39. But i want to count only unique values. How can I do this?
There is not a built-in function for this, as you can see from the several suggestions of how to accomplish this on the Office support site. If you can, you can switch to Google Sheets, and they have a "COUNTUNIQUE()" function.
As described at the link provided above, identify the unique items, either using a filer (this is static) or through repeatedly using the "FREQUENCY()" function. Then count the unique items in a separate step.
Lets say you have the data set in the first column, first you need to remove the repetitions in a second column with the following array formula (confirm the formula with Ctrl+Shift+Enter)
=IF(SUM((A2=$A$2:A2)*1)>1,"",A2)
this formula lists only unique values
I would remove your first 4 digits of your string to create a float number and then count it with the following array formula:
=SUM((IF((RIGHT($B$2:$B$14,4)>=RIGHT(G3,4))*(RIGHT($B$2:$B$14,4)<=RIGHT(G4,4)),$B$2:$B$14,"")<>"")*1)
Please look at the two images for clarification
view with formulas
normal printscreen

How to tell if a cell exists on another Google Sheet

I have 12 sheets in one Google Sheets document labeled for each month (January - December). On each sheet column A contains a project number, e.g. "6091".
I'm trying to find a function that will check all of the other sheets to see if there are duplicate cells in the "project number" column of other sheets.
So: "Do any of the cells in column A, match any of the cells in column A on other sheets".
Is there a quick way to do this?
The formula =arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0))) checks each value in A2:A of the present sheet for being in A2:A of AnotherSheet. If it's there, it returns the position in AnotherSheet, otherwise the output is empty (the error #N/A is suppressed by iferror).
You can use the above for each of the sheets separately. Alternatively, if you are not interested in the positions and just want to know which entries from A2:A are found elsewhere, then add the results for each sheet:
=arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0)) + iferror(match(A2:A, ThirdSheet!A2:A, 0)))
The output is 0 is there is no match, and a nonzero number if there is.
You may try using this to find the number of duplicates:
=counta('JAN'!A:A,'FEB'!A:A)-countA(unique({'JAN'!A:A;'FEB'!A:A})
Where A:A is your column for the data you want to check and the respective files.
This formula counts the total number of data you have, minus the unique data, therefore giving you the total number of duplicates in your dataset.
This formula gives you an overview of the total number of duplicates, however, it doesn't show which cell is a duplicate.
Alternatively, you can add a checker column and input the following formula to check if that specific cell is a duplicate.
=match(cell to check,{range 1;range 2;...range 12})
Alternatively, you may use this formula to find the exact duplicates between the ranges, however this formula does not search within the range itself for duplicates.
=arrayformula(filter(range to check,(countif(arrayformula({Range 1;range 2}),{range to check}))>1))
Personally I think that the last option would be the best as it gives you the exact data to correct.
I am still new to this so hope this helps:)
This formula should work for numerical values:
=COUNT(QUERY({March!A:A;April!A:A},"where Col1="&A2))
If you are searching for text values it would be
=COUNTA(QUERY({March!A:A;April!A:A},"where Col1='"&A2&"'"))
Unfortunately the QUERY function does not work within an arrayformula so you would need to copy the formula down the column. You can add in extra sheets into the { } array as required, separated by a semi-colon
Edit: actually, borrowing from #sandwich, this version should work without the need to copy the formula down the column:
=arrayformula(iferror(match(A2:A,{March!A:A;April!A:A},0)))

Count max value (text+number) occurrences with filtering a specific part of text in excel

I'm having an excel column range (including blank cells) something like:
00EGB00-GE001
00EGB00-GE001
00EGB00-GE001
00EGB00-GE001
00EGB00-GE002
00EGB00-GE002
00EGB00-GE002
00EGB00-GE002
00EGD20-GD101
What I need is to Count total number of similar values and I'm stuck with the logic for counting total unique "similar" values... example "GE" & "GD" separately.
How to count total number of unique "GE" values in the list?
I thought =COUNTIF(B:B,"*GE*") should work but it does not. It gives total count of "GE" but I need to find unique count. Example GE001 & GE002 should be considered as 2 values in total.
Kindly help
EDIT AGAIN: Given further clarification below, and assuming that the data always has the same number of digits, one way to do it is by putting this in Column B:
=RIGHT(A1,5)
Then, if you have Excel 2007 or up, Copy and Paste Values and use Remove Duplicates to leave you with the unique values. Then remove the items with GD, either manually or using a formula.
In this case, the output is:
GE001
GE002
In this case, you can easily see that it's 2. If you have lots of values, you can use COUNTA. Is that what you want?
YET ANOTHER EDIT BASED ON LAST COMMENT: this is probably getting closer:
=SUMPRODUCT(--(MID(A1:A9,9,2)="GE"),1/COUNTIF(A1:A9,A1:A9))
Where the "GE" is hard-coded in the formula above you could also substitute a cell reference where you can alter the value.
Or, if you don't know where the text you want will be exactly because the number of characters change, this will work (but you'd need to be careful with what you were searching on because it might repeat somewhere else in the string):
=SUMPRODUCT(--(ISERR(SEARCH("GE",A1:A9))<>TRUE),1/COUNTIF(A1:A9,A1:A9))
Again, you can replace the "GE" with a cell reference.
As discovered below, though -- blank cells will cause this to fail. There IS almost definitely a way to cater for them (maybe using a FREQUENCY based Array Formula), but if you can live with cleaning out the blank cells then that would be one way of doing it.
LAST EDIT: this will account for blank cells. It is an Array Formula, and CAN be used on whole columns, but that will be quite slow as it takes up a fair bit of calculation effort:
{=SUMPRODUCT(--(MID(A1:A9,9,2)="GE"),IF(ISBLANK(A1:A9),1,1/COUNTIF(A1:A9,A1:A9)))}
As it's an Array Formula, use Ctrl + Shift + Enter to input it.

Resources