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.
Related
I have created an excel sheet to have an overview over costs in my projects, however, I also need an overview of costs per category in my projects. I googled it and tried to find examples online, however, it only returns a value of 0, which shouldn't be the case. Can anyone help me? The sheet looks like below.
I am going by the SUMIF function to group by category but my excel sheet is a bit more complex than that so I tried to adjust it accordingly as seen in the code below. No matter what I do it either returns an error or 0.
=IF(B12=B8;"";SUMIF(B12:B39;B12;J12:BE39))
In the formula above I am trying to sum the costs of a category that could be written in B12, for example, Software development. For confidential reasons, I cannot show the actual filled out excel sheet.
sumif does not work with summing multiple columns. Instead use a sumproduct statement instead like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$BE$39)))
A detailed explanation to how this works can be found here
Edit:
I sense a follow up question coming, how to skip certain columns. Because as you have set it up now, it will count the entire range from J12 to BE39, in which you have both forecast costs and actual costs. I guess this is to compare the costs to what was projected and what the actual costs are. Right now it will count both the projected and actual cost, doubling up. To prevent this you can enter every second column separated by a + like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$J$39+$L$12:$L$39+$N$12:$N$39)))
Also I have added $ signs to all non-changing values so it will work when dragging down the fill handle on the formula to populate the below cells.
I've a question regarding columns and finding non zero values with there labels.
Hopefully the pictures will make my problem/struggle a bit better to understand.
Basically, there are columns to the right that show labels and hours that a team loaned in or out.
The values are found through a formula that shows per label the totals amount of hours spent.
Now I want to have on my overview page the two columns to the right with only labels showing the labels that contain hours. I've tried to use multiple if variables but that didn't seem to work :(
So at the end it should show something like this (I now manually typed the labels and data):
I did a quick recreation of your data structure to test this.
Using Array Formulas should get you the desired results in the current structure of your worksheet:
For range Loaned in you'd need the formula to be
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($I$4:$I$14>0,ROW($4:$14),""),ROW(A1)),8)),"")
Where 8 is a reference to the return column. For the range directly to the right, you'd use the same formula, just adjust 8 to 9. And for range Loaned Out you'd need
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($K$4:$K$23>0,ROW($4:$23),""),ROW(A1)),10)),"")
And for the range directly to the right you would again change the 10 to a 11. Again, both of these are array formulas, so they have to entered slightly differently. See the link for further assistance with array formulas.
This is not trivial. If you cannot work with filtering or programming, you should make use of matrix formulas. I include an example with two formulas: 1st in D1:D5, 2nd in F2:G5. Enter them with Ctrl+Shift+Enter. Also, you should use an extra column to determine the "valid" rows. (You could put it all in one formula, but it would look even more complicated.)
Sorry for German excel. Wennfehler = iferror, kkleinste = small, zeile = row, wenn = if, bereich.verschieben = range.offset.
So I am trying to create a spreadsheet at allows a character in game to total the party inventory.
I am trying to sumif multiple columns based on the same criteria.
So say I am trying to sum all the rope they have.
In column A is the Item descriptions
In columns B-E are the different totals for each party member (one column per person)
Each party member has 50 rope, so I am expecting 200 rope.
I have used this formula:
=SUMIF(A:A,"Rope: Hemp",B:E) and it is only returning 50 as a value, If I utilise cell values (A1:A100 etc.) it returns a value of Zero.
I have been told that Sum Product could works so I also tried that:
=SUMPRODUCT((A1:A100="Rope: Hemp")*(B3:E100)) and I still get the incorrect result.
What am I doing wrong?
EDIT:
Here are some photos.
Here is my Raw Data. As you can see I have the inventory and tallies, when you look at rope it says 150, and this was calcualted by summing the B to E cells, however as the list is going to move and grow I thought SUMIF would be better.
As stated above, I have used a SUMIF making the range Columns B through E, and it only returns a value of 50 (I'm assuming Column B)
so came up with this:
=SUMIF(A3:A40,"="&J17&"",B3:B40)+SUMIF(A3:A40,"="&J17&"",C3:C40)+SUMIF(A3:A40,"="&J17&"",D3:D40)+SUMIF(A3:A40,"="&J17&"",E3:E40)
Which works, but I can only assume that sumif only work with ONE target range... And I tried curly brackets as well...
So, I did also use cell J17 for the object you are looking for, so you can drag it down, the "*" will find all occurences of "Rope: Hemp", or "Rope: Nylon" etc. I get a total of 150 as there are only 3 characters with rope...
Hope it helps. Someone else may have a better / neater suggestion!
I just tested it by entering Rope, rapier and rations into J17 and got the results I expect.
Image of spreadsheet:
I'm working on data from a population of people with allergies. Each person has a unique ExceptionID, and each allergen has a unique AllergenID (451 in total).
I have a data table with 2 columns (ExceptionID and AllergenID), where each person's allergies are listed row by row. This means that the ExceptionID column has repeated values for people with multiple allergies, and the AllergenID column has repeated values for the different people who have that allergy.
I am trying to count how many times each pair of allergies is present in this population (e.g. Allergen#107 & Allergen#108, Allergen#107 & Allergen#109,etc). To keep it simple I've created a matrix of 451 rows X 451 columns, representing every pair (twice actually because A/B and B/A are equivalent).
I somehow need to use the row name (allergenID) to lookup the ExceptionID in my data table, and count the cases where that matches the ExceptionIDs from the column name (also AllergenID). I have no problem using Vlookup or Index/Match, but I'm struggling with the correct combination of a lookup and Sumproduct or Countif formula.
Any help is greatly appreciated!
Mike
PS I'm using Excel 2016 if that changes anything.
-=UPDATE=-
So the methods suggested by Dirk and MacroMarc both worked, though I couldn't apply the latter to my full data set (17,000+ rows) because it was taking a long time.
I've since decided to turn this into a VBA macro because we now want to see the counts of triplets instead of pairs.
With the 2 columns you start with, it is as good as impossible... You would need to check every ExceptionID to have 2 different specific AllergenID. Better use a helper-table with ExceptionID as rows and AllergenID as columns (or the opposite... whatever you like). The helper table needs a formula like:
=COUNTIFS($A:$A,$D2,$B:$B,E$1)
Which then can be auto-filled. (The ranges are from my example, you need to change them to your needs).
With this helper-matrix you can easily go for your bigger matrix like this:
=COUNTIFS(E:E,1,INDEX($E:$G,,MATCH($I2,$E$1:$G$1,0)),1)
Again, you can auto-fill with this formula, but you need to change it, so it fits your needs.
Because the columns have the same ID2 (would be your AllergenID), there is no need to lookup them because E:E changes automatically with the auto-fill.
Most important part of the formulas are the $ which should not be messed up, or you can not auto-fill it.
Picture of my self-made example (formulas are from the upper left cell in each table):
If you still have any questions, just ask :)
It can be done straight from your original set-up with array formulas:
Please note that array formulas MUST be entered with Ctrl-Shift-Enter, before copying across and down:
In the example pic, I have NAMED the data ranges $A$2:$A$21 as 'People' and $B$2:$B$21 as 'Allergens' to make it a nicer set-up. You can see in the formula bar how that looks as a formula. However you could use the standard references like this in your first matrix cell:
EDIT: silly me, N function is not needed to turn the booleans into 1's and 0's, since multiplying booleans will do the trick. Below formula works...
SUM(IF(MATCH($A$2:$A$21,$A$2:$A$21,0)=ROW($A$2:$A$21)-1, NOT(ISERROR(MATCH($A$2:$A$21&$E2,$A$2:$A$21&$B$2:$B$21,0)))*NOT(ISERROR(MATCH($A$2:$A$21&F$1, $A$2:$A$21&$B$2:$B$21,0))), 0))
Then copy from F2 across and down. It can be perhaps improved in technique with sumproduct or whatever, but it's just a rough example of the technique....
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.