Counting names using three columns - code - excel

Using the following input data, I am trying to extract count for each name's (column D) type.
input example:
the current code, picks up count if column b is unique.
desired output:
RBS = 5, CA = 1, SG = 1,
I found this code and updated it to my requirements. however, I can not get it to output results, for the following condition:
if column B (deal), column C (total) and column A (date) are unique (non-duplicate) then count the name's type as 1 otherwise if both three columns are duplicate, then only count as one.
(Desired Output)
Hope the example above clarifies the logic a little clearer.
Any help on this issue would be very much appreciated.
Kind regards

No need for complex VBA here - a "simple" formula will do:
=SUM(--NOT(ISERROR(SEARCH(C1,Input!$D:$D))))
(This assumes the name of the bank is stored in cell C1)
Please note that you need to enter this as an array formula, i.e. press Ctrl-Shift-Enter!

Related

Count of values which appear more than once in a column

In my excel column I have values as such:
ID
a
a
a
b
c
c
d
e
I would like to return the count of ids which occur twice or more. In this case answer is 2 (a,c).
Constraints:
No helper cols or one at most(There are a ton of other filters to be added to the countifs which are not relevant to the question,adding helpers would mean 12+ extra columns, one for each month)
2.No VBA ( UDF is ok)
3.Formula result in single cell.
The current formula which I have tried:
=COUNTIFS(F13:F22,COUNTIF(F13:F22,">=2"))
gives me 0.
Thanks in advance.
Hmm with no specific order of values, try:
=SUM(IF(COUNTIF(A2:A9,A2:A9)>1,1/COUNTIF(A2:A9,A2:A9),0))
Enter as array through CtrlShiftEnter
Another variant would be:
=SUMPRODUCT((COUNTIF(A2:A9,A2:A9)>1)/COUNTIF(A2:A9,A2:A9))
With the advantage you won't have to enter as array.
Would you choose to add criteria I believe that the second formula is a bit more userfriendly adding them in, like so (edited your sample data a little to show):
=SUMPRODUCT((B2:B9=1)*(C2:C9="x")*(COUNTIF(A2:A9,A2:A9)>1)/COUNTIF(A2:A9,A2:A9))

How to count multiple text in multiple columns

I am Working off a large table in Excel and I want to sort the data into categories. What I’m trying to do is get Excel to count how many times a criteria in column C, D, & E occurs and returns the value. So look through C:C pick “Company”, then look through D:D for “Full Time – Temp” and then E:E for a location such as “Factory”. See link to sample table below.
Example:
G4 =COUNTIFS($C:$C,"company",$D:$D,"full time - temp",$E:$E,"home") and it returns 0
I4 =COUNTIFS($C:$C,"company bilingual",$D:$D,"bilingual - FT - perm") and it will return 3
My problem is column E
If I wanted to return in cell J4 how many “Company Bilingual” are “Bilingual - FT – Perm” and located in “Factory” I get 0.
I’ve tried using
J4 =COUNTIFS($C:$C,"company bilingual",$D:$D,"bilingual - FT – perm",$E:$E,"Factory") but it returns 0 and what I want it to return is 2, which I understand it is saying there is no Factory cell on its own, all the cells that have Factory have 3 items in them e.g Factory - Dallas. So I want to count all the factories in column E but not where the factory is actually located.
In summary what I want to do is find a function or array that will count one unique occurrence in column C, D, and E. If a cell in a column has more than one word I would like to be able to pick one word and ultimately still count all occurrences in the other columns and return a value.
In my research I have come across different suggestions but none that helps my problem.
I hope I've explained my problem, any assistance is greatly appreciated.
Screenshot of table
I suggest you make the criteria table and mention your criteria there as shown by me in the snapshot.Giving due credit to #Harsha Vardhan, his suggestion is correct approach as given in his comments. I have made a fully working example for clear understanding.
For partial string match I used a concatenated string in I2 ="*"&"Factory"&"*"
Criteria Table is in the Range G1:I4 and Results are in the Range J1:J4
Formula to be entered in J2 to J4 respectively are as per criteria mentioned in the table.
=COUNTIFS($C:$C,$G$2,$D:$D,$H$2,$E:$E,$I$2)
=COUNTIFS($C:$C,$G$3,$D:$D,$H$3)
=COUNTIFS($C:$C,$G$4,$D:$D,$H$4,$E:$E,$I$4)
Results are as per your requirement as shown in the snapshot.
EDIT DATE 23-06-2016
This has reference to OP's comments on 22nd and 23rd June 2016. There is no change in the formulas. It is required that conditions are put correctly in the criteria table. As per new criterion specified by OP, following snapshot shows that correct results are obtained. Further file count multiple text 23062016 has been uploaded for perusal.

Excel: match two columns and output third ... AND... there are multiple instances in each column

Working off a previous post:
Excel match two columns and output third
I have values in column A that are not unique and values in column B that are not unique, but together column A and B produce unique combinations:
A B C
1 Red Car Result#1
2 Blue Boat Result #2
3 Red Boat Result #3
4 Green Car Result #4
Let's say I want to find a match where Column A = Red and Column B = Boat which should return the corresponding value in Column C which should be Result #3.
Using the previous post's solution:
=IF(MATCH("Red",A1:A4,0)=MATCH("Boat",B1:B4,0),INDEX(C1:C4,MATCH("Boat",B1:B4,0)),0)
This would actually return value the first match for Boat in column B which would be result#2 rather than the intended result#3 where the match was true.
Any ideas on how to modify or write a function that would specify to retrieve information relative to specifically where the match was true (without using VBA)?
I've thought of a possible work around by creating another column that combines Col A and B to make a unique identifier but I was hoping to avoid that.
Thanks! Really appreciate it and sorry about the table formatting. I'm still very new at this.
You can retrieve a two column match using the AGGREGATE function to force anything that does not match into an error and ignore the errors.
      
The formula in E6 is,
=IFERROR(INDEX(C$1:C$99,AGGREGATE(15,6,ROW($1:$99)/((A$1:A$99="red")*(B$1:B$99="boat")), ROW(1:1))), "")
You are actually using the SMALL sub-function of the AGGREGATE function so you can get the second, third, etc. successive matches by increasing the k paramter. I done this above by using ROW(1:1) which equals 1 but will increase to 2, 3, etc as the formula is filled down.
Creating a third column is the most efficient solution. However if you absolutely have to avoid it, you could use a complicated formula like this:
=INDEX($C$1:$C$6,MATCH(A11,$A$1:$A$6,0) + MATCH(B11,OFFSET($A$1,MATCH(A11,$A$1:$A$6,0)-1,1,COUNTA($A$1:$A$6)-MATCH(A11,$A$1:$A$6,0),1),0)-1)
But the condition is that the lookup table is sorted for both column 1 and 2.

Sort Order formula to alphabetise in Excel

I am currently drawing up a spreadsheet that will automatically remove duplicates and alphabetize a list:
I am using the COUNTIF() function in column G to create a sort order and then VLOOKUP() to find the sort in column J.
The problem I am having is that I can't seem to get my SortOrder column to function properly. At the moment it creates an index for two number 1's meaning the cell highlighted in yellow is missed out and the last entry in the sorted list is null:
If anyone can find and rectify this mistake for me I'll be very grateful as it has been driving me insane all day! Many thanks.
I'll provide my usual method for doing an automatic pulling-in of raw data into a sorted, duplicate-removed list:
Assume raw data is in column A. In column B, use this formula to increase the counter each time the row shows a non-duplicate item in column A. Hardcord B2 to be "1", and use this formula in B3 and drag down.
=if(iserror(match(A3,$A$2:A2,0)),B2+1,B2)
This takes advantage of the fact that when we refer to this row counter in our revised list, we will use the match function, which only checks for the first matching number. Then say you want your new list of data on column D (usually I do this for display purposes, so either 'group-out' [hide] columns that form the formulas, or do this on another tab). You can avoid this step, but if you are already using helper columns I usually do each step in a different column - easier to document. In column C, starting in C3 [C2 hardcoded to 1] and drag down, just have a simple counter, which error-checks to the stop at the end of your list:
=if(C2<max(B:B),C2+1," ")
Then in column D, starting at D2 and dragged down:
=iferror(index(A:A,match(C2,B:B,0)),"")
The index function is like half of the vlookup function - it pulls the result out of a given array, when you provide it with a row number. The match function is like the other half of the vlookup function - it provides you with the row number where an item appears in a given array.
Hope this helps you in the future as well.
The actual reason that this is going wrong as implied by Jeeped's comment is that you can't meaningfully compare a string to a number unless you do a conversion because they are stored differently. So COUNTIF counts numbers and text separately.
20212 will give a count of 1 because it is the only (or lowest) number.
CS10Z002 will give a count of 1 because it is the first text string in alphabetical order.
Another approach is to add the count of numbers to the count if the current cell contains text:-
=COUNTIF(INDIRECT("$D$2:$D$"&$F$3),"<="&D2)+ISTEXT(D2)*COUNT(INDIRECT("$D$2:$D$"&$F$3))
It's easier to show the result of three different conversions with some test data:-
(0) No conversion - just use COUNTIF
=COUNTIF(D$2:D$7,"<="&D2)
"999"<"abc"<"def", 999<1000
(1) Count everything as text
=SUMPRODUCT(--(D$2:D$7&""<=D2&""))
"1000"<"999"
(2) Count numbers before text
=COUNTIF(D$2:D$7,"<="&D2)+ISTEXT(D2)*COUNT(D$2:D$7)
999<1000<"999"
(3) Count everything as text but convert numbers with leading zeroes
=SUMPRODUCT(--(TEXT(D$2:D$7,"000000")<=TEXT(D2,"000000")))
"000999" = "000999", "000999"<"001000"

VBA Code to sum values in one column based on the value in another column in excel

I am a VBA Newbie and a first timer on this forum - I have followed all the instructions on the "how to ask" page - I may have missed something please do advise
I am creating an EV report for project tracking based on the following column headers (showing only a few for brevity)
"TaskName" "Status" "BaselineStart" "BaselineFinish" "BaselineEffort"
need to sum up the values in the BaselineEffort column in 7 day increments after checking if the value in the BaselineFinish column is less than or equal to the 7th day value
I believe the answer lies in using arrays, but need handholding with that concept to understand how it works
Pivot and Excel formulas dont work for me because the table is dynamic while the report is static and I need to remove user intervention in creating the report
Thanks in advance
say that the criteria column starts in A1 and the colume to be summed starts in B1
do while not isempty(range("a1").offset(x,0))
if range("a1").offset(x,0) = SomeValue then
sum = sum + range("a1").offset(x,0)
end if
x = x + 1
loop
this code will run until it has looked at each item in column A, and add the value in column B to a sum I called "sum" if the value in column A equals "SomeValue." I doubt you can actually use the variable name "sum."
I hope that's useful.

Resources