I am trying to count groupings of elements in a list, in Excel, with groupings defined by 2 conditions: same Element and same Group code, as shown in the image below. The column C formula seems to throw errors as shown in orange highlighting in cells C9-C11. The formula for column C is displayed starting in column D. My expected grouping count is shown in column L with explanation starting in column M. Cells L9-L12 show what I expect the element count to be for Element X/Group 0.
Is there a correct formula for counting multiple-criteria groupings in Excel 365? I have tried various iterations of countifs() and sumproduct (See column D of the screencap) with no luck yet.
Post possible solution:
Now showing a scenario where the solution doesn't hold up (holds up in all other 16 scenarios I ran but not this one ???), see the orange cells with strange output versus expected output in yellow:
OK well in the first iteration of your question what seemed like a long time ago we all assumed that you wanted to count the total number of unique groups you have got so far. Now it's looking a bit different - the example implies that if both the element and group are repeated later on you want to revert back to the count of that element and group only and not the total count. I think what you want is a match like this:
=MATCH(A4&B4,SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)-
MATCH(A4&"*",SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)+1
Could be simplified using Let but it's late here and it's tentative anyway.
However the sorting assumes that the group keeps on increasing within each element and that wasn't the case in the first iteration of your question. You could try Sortby just sorting on the Element but that will have to wait till tomorrow.
EDIT
Here is my revised formula - plz try it.
=LET(range,A4:B$4,
unique,UNIQUE(range),
uniqueElement,INDEX(unique,0,1),
sortby,SORTBY(unique,uniqueElement,1),
sortElement,INDEX(sortby,0,1),
sortGroup,INDEX(sortby,0,2),
MATCH(1,(sortElement=A4)*(sortGroup=B4),0)
-MATCH(A4,sortElement,0)+1)
You could also use Take instead of Index. I've removed the filter for clarity because there aren't any blanks in the test data.
Related
I'm creating a personnel tracker, I'd like to "double check" that I have the people I need on a given day. With people as rows, and dates as the columns, I want to check the column for a particular day to see if I have coverage at a glance.
=IF(SUMPRODUCT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"}))>=7,"T","F")
This seems to work, but after some experimentation it is counting other strings in the column (so W or F might match on WF) which isn't what I want.
COUNTIFS works differently when you use an array as the criteria. It outputs an array the size of criteria showing have many matches were made for each item in criteria. Instead of using SUMPRODUCT, you need to count the number of values above 0. I've solved it by forcing every value of 0 in the array to be an error, and counting all non-errors.
=IF(COUNT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"})^0)>=7,"T","F")
I am having trouble with Excel. I have a data set containing bibliography. For each row I have each author from a specific title, separated by columns. I wanted to make an association between authors to see which have publications together and how many times.
Example of data set:
full view
Output wanted:
full view
I have approximately 43 columns by 500 rows. I've already tried COUNTIFS and SUMPRODUCT but both don't give me the output that I want.
Thank you for your help :)
There may be an easier way than this, but with 43 columns (a lot of co-authors?) I can only think of using an array formula, so the method is:-
(1) Get row totals of original data for first author
(2) Get row totals of second author
(3) Multiply them together to get rows (publications) where both authors occur.
(4) Optional - check that each row total is greater than zero -shouldn't be necessary unless author's name is repeated.
(5) Add them all up.
=SUM(--(MMULT(N($A$2:$D$20=G$1),TRANSPOSE(COLUMN($A$1:$D$1))^0)*MMULT(N($A$2:$D$20=$F2),TRANSPOSE(COLUMN($A$1:$D$1))^0)>0))
Must be entered as an array formula using CtrlShiftEnter.
I have just used initials to demonstrate the method.
I have formatted them using "#" to make the zeroes appear as blanks.
Firstly, apologies if this is covered somewhere deep within the site, I have looked through a lot of other posts and none of the solutions have worked for me.
I'm creating a workbook for a local league I'm involved in and this is the only sticking point I'm coming up against.
In cell J55, I have the formula:
=IF(C11=H55, COUNTIF(D11, "="&E11),0)+IF(C19=H55, COUNTIF(D19, "="&E19),0)
(I've simplified this to only look at rows 11 & 19 for the purposes of this question)
So what I'm essentially saying is if the team name is equal to the corresponding name in the table, count if the scores for both teams are equal. Basically I'm trying to get the number of games that end in a draw.
So at it's core, my formula is looking for whether 2 cells are equal. This is fine, other than it is counting even if the score cells are blank.
So if you refer to the below image, in J55, I'm getting the returned value of "2". However for the values I've populated in the results (just the scores in the first game) it should be returning a value of "1".
If anybody can help in any way it would be a great help.
To count the number of Draws this formula which performs array like calculations will count the number of occurences where where the team name in H55 is equal to the team name in column D or F and when the scores in column D and E are equal:
=SUMPRODUCT((($C$11:$C$21=H55)+($F$11:$F$21=H55))*($D$11:$D$21=$E$11:$E$21)*($D$11:$D$21<>"")*($E$11:$E$21<>""))
Copy down as required.
COUNTIFS options
Based on your formula above, adding the checking for not blank cells using COUNTIFS.
=IF(C11=H55, COUNTIFS(D11, "="&E11,D11,"<>"&""),0)+IF(C19=H55, COUNTIFS(D19, "="&E19,D19,"<>"&""),0)
COUNTIFS is probably the slightly better option as it does not use array calculations. However for a small data set it wont make a noticeable difference in calculation time for most users.
I have two descending running totals, and I want to sum the last item in each running total.
I would like the total to be in a single cell, and the total in this instance to be £2500 + £4492.55. As the running total continues, I expect the total in this cell to update.
(Apple Numbers is similar to Excel, which is why I have used the Excel tag here).
This approach works only if the calculation is not below the column of values, but above it:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,C:C,1)-1)
Edit
Microsoft Support pages for Index and Match. With the extraordinarily large number and the 1 as the last argument, Match will return the position of the last populated numeric cell. Index will then return the value of that cell. Repeat, but return the second last row, by subtracting a 1 from the Match result. Add the two results.
Edit two
Since you did not want to do what you first said you want to do, here is a formula for what you currently say you want to do. Assume the first list of numbers is in column C and the second list of numbers is in column G:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,G:G,1))
Edit three
You've clarified in the comments that you're using Apple Numbers, not Microsoft Excel. Unfortunately the above formulae may not work in that system, and help for that probably is out of the scope for Stack Overflow.
I was overcomplicating things.
MIN(C:C) + MIN(G:G) yielded the result I was looking for.
I am new to Stackoverflow, so please let me know me if there is not enough information. I have had many helpfull insights by using StackOverflow in the past, but I cannot find any helpful thread online, so I hope you can help me.
I've been working on a excel (2013) problem for a while now. I am trying to build a marketing agenda to store and keep track of our mailing campaigns. The campaigns themselves are send via another system, but we miss the ability to plan our mailing campaigns in advance. Since we are active on different markets in Europe, we decided to have a general mailing (for all regions) and a region specific mailing campaign (both are in the same agenda). Besides this we also want to display the mailing focus (different brands). It is my idea to return this as visual as possible (to make it usable for all users). I have add a small picture to show my desired end-result (however without any data at this moment).
At this moment, the users are going to use a (Google)form to enter the campaign information and this data is downloaded to the worksheet (by doing so all users can add new campaigns and everyone always has access to the most recent data). This part works well.
I am using a helper sheet to check if the dates fall in a campaign range, if it does fall in a campaign range it should return the mailing ID (also the row number). I have another form which uses this data to search for the right brand and displays visually (with a lot of conditional formatting).
The problem arises in the helper sheet (when I check if a date fall into a campaign range). I have been able to get it working (more or less) with the following formula:
=IF(SUMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper!$D$2:$D$100>=$B4);RIJ(CountryHelper!$C$2:$C$100))=0;"";INDEX(CountryHelper!$A$2:$A$100;SOMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100))))
In this formula, CountryHelper!C:C is referencing the StartDate of the mailing campaing. D:D will reference the column of the EndDates and A:A has the mailing ID. Cell B4 is the date that needs to be checked.
At first it looked this worked perfectly. If a date fell in a date range then it would return the ID. After a little playing around with this a problem came to light. It only works with non overlapping dates, once dates overlap excel will add the row numbers together and it would not work any more.
Is it possible to get the sumproduct formula working and returning only the first ID. I am aware that I then have to make another 2 formulas which return the second and third ID ( I am certain we do not get more than 3 overlapping dates). This is also the part where I get lost. I've tried to use a MIN and MAX variation wit the following sumproduct formula:
=SUMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper_RSEU!$D$1:$D$100>=$B4);ROW(CountryHelper!$C$1:$C$100))
This will return either a 0 (with MIN) or 100 (With MAX). I think this is caused by the formula (for now it only searches the first 99 rows). I also have ventured into VBA / UDF to get this done, but as I understand it this is not possible.
Anyway, I am sorry for the long story, I hope that my problem is clear and you can help me. If you need any more information.
Thank you!
empty Marketing Agenda overview
The SUMPRODUCT is a kind of swiss army knife Excel function. But here it is wrong because, as you already have seen, it really calculates a SUM at the end. Mostly it works because it first multiplies the 0 or 1 of the conditions with the row numbers so only the row numbers which fulfills the conditions comes into the sum. But if two or more row numbers fulfil the conditions then they were added together.
Are you familiar with array formulas? The following array formula should be what you want:
{=INDEX(CountryHelper!$A$2:$A$100;MIN(IF((CountryHelper!$C$2:$C$100<=$B4)*(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100)-1)))}
To create a array formula put the formula into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter]. Then the curly brackets should appear automaticaly.
How it works:
{IF((CountryHelper!$C$2:$C$100<=$B4)*(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100)-1)}
Gets a array of row numbers or FALSE {FALSE, rowNumber, FALSE, ...}. If both conditions are fulfilled then it gets the row number - 1, if not then it gets FALSE.
The MIN function then gets the smallest (row number - 1) from this array.
The INDEX then indicates this smallest (row number - 1) which fulfills the conditions.
It subtracts 1 from the row number because your INDEX range starts at row 2. If the row number 2 fulfills the conditions then it is the index 1 within this range, if row number 3 fulfills the conditions, it is the index 2 and so on.
Why it only works as array formula? Because the IF function do not creates a array by default even if their "Value_if_true" is a range. Within the array context it does exact this.