I'm working on a sensitive Excel file where I'm not allowed any VBA code, so I have to help myself with basic formulas in Excel. Please note that I am not allowed to add extra columns and the solution has to be in one single cell. What I have are two columns:
Column A has numbers from 1-10.
Column B has numbers from 1-10.
I'd like to know e.g. for all 3's in A, how many 5's are in B.
The result would be as well seen with the use of two filters, but I don't want to do this over and over again, since the size of the columns will only get bigger.
I tried to use INDEX-MATCH command in the COUNTIF, but it's not that simple. The main problem is to define how to look and search in each row and then count/sum/whatever.
Does anyone have any ideas?
Though a function not available in versions of Excel before 2007, it seems:
=COUNTIFS(A:A,3,B:B,5)
met the requirement here.
Related
So honestly I feel really dumb here. I have a very large file that has a lot of blank values where there should have populated a name, and I wanted to use a formula to fill those in. The data that I have is what appears in Columns A and B: A bunch of customer names and corresponding transaction codes (that repeat several times over), but blank spaces in a lot of places where the customer name should be. My attempt to fix this was to try filtering the data to get rid of the blank spaces, and use a VLOOKUP formula off that new table. Any ideas on what I'm doing wrong here? I don't care if it's a VLOOKUP, I just know there's an easier way to fix this that I'm not seeing, but none of the posts I've found fixed my issue...Thanks for any help you can give. Snapshot of Excel Table
Vlookup only performs matching left-to-right: the matching column has to be the first column of the range(D2:D13).
If you have Excel 365, you can use Xlookup:
=XLOOKUP(B7,E$2:E$13,D$2:D$13,,0)
or if not, you can use Index/Match:
=INDEX(D$2:D$13,MATCH(B8,E$2:E$13,0))
It might be more convenient to test for blank cells in column A and fill them in using a separate column if so, eg in C2:
=IF(A2="",XLOOKUP(B2,E$2:E$13,D$2:D$13,,0),A2)
I've got a fairly large spreadsheet with survey data that I'm trying to summarize. The first tab of the spreadsheet has all the survey data and I'm trying to summarize on the second tab.
Column A in my second tab will have all the unique store numbers listed. I'd like Column B of the second tab to list the number of times a customer answered "Very Satisfied" in columns R through Z on the first tab for a particular store. The store number is also listed on the first tab in column DY.
I've never tried nesting combining COUNTIF and VLOOKUP before or maybe that's not even the best way to do this. My feeble attempt looks like this
=COUNTIF(Sheet1!DY:DY,VLOOKUP(A2,Sheet1!R:Z,0,FALSE))
And, of course, this returns "#VALUE!". I know I need "Very Satisfied" in there somewhere but I can't wrap my head around the nesting. Any suggestions? Thanks in advance.
Use SUMPRODUCT()
NOTE: I am using full columns here but it would work better if one would limit the references to just the rows that have data.
=SUMPRODUCT((Sheet1!DY:DY=A2)*(Sheet1!R:Z="Very Satisfied"))
I have two spreadsheets. I'm trying to use VLOOKUP, but it simply is not being nice. The cell that's suppose to be updated does not.
-Spreadsheet A has indices that need to be paired with Spreadsheet B indices.
-Then I need to get the corresponding value to that indices. Those values are one cell to the right of the indices in Spreadsheet B.
-The value in Spreadsheet B then needs to be placed in its appropriate cell back in Spreadsheet A.
If someone could help that would be great and ... fabulous. If you need more details or clarification let me know. I have a feeling it might be my using of Table Name across spreadsheets as the culprit for it not working properly.
Try using and Index Match combo function
Index('Column/array with return value',MATCH('Value to match','Array to find the value',0-For an exact match),'column number of the Column/Array to look in')
I am not a fan of VLOOKUP as I almost always find errors with it. There are plenty of indexMatch examples too on here and Google.
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....
First time question and I hope it's easier than I'm making this.
Can I use a variable inside a COUNTIF formula?
Currently my formula is:
=COUNTIF($C$2:$C$415,R6)
I would like to have $415 as my variable. I have tried something along the lines of:
D1=415=COUNTIF($C$2:$C$(D1),R6) ..
but obviously get a error.
The reason I need this is column C will constantly be incrementing as I add more rows.
Instead of going into each of my formulas and updated 415 to 416, 417 etc, I would like to just define a Cell that can be my variable, or total rows.
Currently Column C can have blank cells, so I can't have a macro that finds the next empty cell.. but I do however have Column A with a constant populated cell and stops at the last ticket. However Column A is unrelated to the COUNTIF.
UPDATE 1
I'd also like to mention that I'd be using this variable in many formulas in the spreadsheet. Not only COUNTIF's. Also, the COUNTIF contains text.
UPDATE 2
Actually, I figured it out! I am using this formula instead:
=COUNTIF(INDIRECT("C"&D1&":A"&D2),R6)
I'm putting D1=2 and D2=415 and will just update cell D2 with how many rows I have.
I guess I just needed to ask the question thoroughly to fully understand what I wanted!
Thank you in advance for all help, tips and suggestions.
Would "=COUNTIF($C:$C,R6)" do the trick? This will apply COUNTIF to the whole of column C. It's an easy solution, but probably not the most efficient.
I prefer tables for storing data; as new data is added, the table automatically expands and the columns are already labeled (much like Named Ranges). Then you can have =COUNTIF(Table1[Column1],"Criteria"), which will encompass any new rows added to the table automatically. Especially helpful if you have multiple tables in the same column.