Hello my dear excel friends!
My "List" table consists of 10 columns that I filter by needed criterias in the second tab, which works perfectly. Now I have problems with the following filtering:
Cell B7 = Name
Cell B8:F8 = Items 1-5
Cell B9:F8 should be the order number (different amount for each item) of the respected items in the cells above.
Depending on the Name the items are spilling differently without any problems with
=IFERROR(TRANSPOSE(UNIQUE(FILTER(List[Item];(List[Name]=$B$7))));"")
Now I want to spill out the order numbers for each item in each column. The amount of orders can differ depending on the column. Unfortunately for now I can do it only for one column and have to copy the function to the next column:
=IFERROR(UNIQUE(FILTER(List[Order];(List[Item]=B8)*(List[Name]=$B$7)));"")
I have tried to do it with IFS but could not achieve the needed results. I can imagine something like B9# but somehow can not implement it into my function. Is there a way to do it?
Very difficult to give a rigorous solution for such a case. The following is convoluted though should work for smallish ranges:
=LET(μ,List[Item],κ,List[Name],η,B7:B11,ρ,MAX(COUNTIF(κ,η)),λ,TRIM(MID(FILTERXML("<a><b>"&TEXTJOIN(REPT(CHAR(32),50),,IFERROR(IF(INDEX(TRANSPOSE(κ),SEQUENCE(,ROWS(κ)+1))=η,TRANSPOSE(μ),""),"</b><b>"))&"</b></a>","//b"),SEQUENCE(,ρ,1,50),50)),IFERROR(INDEX(λ,SEQUENCE(ROWS(η)),SEQUENCE(,ρ)),""))
I've assumed that B7:B11 is your list of names. Amend as required.
In my opinion a non-spill formula to be copied down is preferable.
Related
I have array of numbers in a single column like this:
I want only that numbers for which corresponding negative numbers exist. If number exist 2 times, but negative number exist only one time, then I wanted to retain one positive and one negative number. Similarly, if number exists 3 times, and negative number appears only two times, then I want 2 set of numbers including positive and negative. In this case, I wanted to get output:
5 2 -2 -5
Orders of numbers are not relevant for me. Please do not use VBA. You can create multiple column and apply filter at the end.
Thank you for the response, but I wanted to get the data in column next to the values. Like:
5
2
-2
-5
Please help.
Here's another Office 365 solution:
Name the data range DATA
Put this formula anywhere: =CONCAT(REPT(-ROW(A1:A100)&" "&ROW(A1:A100)&" ",COUNTIF(DATA,"="&ROW(A1:A100)*IF(COUNTIF(DATA,"="&-ROW(A1:A100))<COUNTIF(DATA,"="&ROW(A1:A100)),-1,1))))
That will output the pairs into one cell.
Here's a slightly modified Step 2, which excludes duplicates: =CONCAT(IF((COUNTIF(DATA,"="&-ROW(A1:A100))>0)*(COUNTIF(DATA,"="&ROW(A1:A100))>0),-ROW(A1:A100)&" "&ROW(A1:A100)&" ",""))
Looks like this:
The data doesn't need to be sorted. Both methods work up to 100, but you can easily expand that by changing A100 to A1000 or whatever you need.
Use the vlookup formula to identify the rows, and you can use the Filter & Unique formula to get the list, or a pivot table.
First, immediately next to your data use the formula:
=vlookup(A1*-1,$A$1:$A$1,1,0)
For non-365:
This will produce an error for each instance that doesn't have a match. You can filter at this point to get your list from the existing table. You can also create a pivot table under the Data tab of your ribbon and inserting a pivot table. Filter the #N/A from there to get an exclusive list without hidden rows.
For 365:
You can use the following combination of formulas to get the exclusive list as well.
=UNIQUE(FILTER(B1:B8,ISNUMBER(B1:B8)),0,0) or =UNIQUE(FILTER($B$1:$B$8,ISNUMBER($B$1:$B$8)),0,0) should yield the same results
As ScottCraner mentioned, you can circumvent the helper column in 365 by modifying the formula a bit more:
=UNIQUE(FILTER(A1:A8,ISNUMBER(MATCH(-A1:A8,A1:A8,0)),"")
The Match here is doing something similar to the Vlookup, but housing that logic within the formula, so it's a cleaner solution in my opinion.
Using your data the result was { -5,-2,2,5 }
These are spill formulas so you only need to put it in one spot and it will expand the formula over the adjacent cells below where it's entered for however many cells needed to list all the unique numbers that occur. It takes into account the negatives and so on. This may be a 365 formula, so if you're on another version of excel it may not work.
Edit: Adjusted the instructions to fully address the question.
I have a sheet with 2 columns. ID and SearchTerm
ID has the same ID# for multiple SearchTerms.
I am trying to search for example ID# 25 and then be able to show all results on a separate sheet. Without having to search for the ID number and then Copy and Paste the columb.
I tried doing a vLookup, but it only gives me back the first SearchTerm based on the ID.
For only 7225 rows of data, an array formula isn't too bad, speed-wise (enter it as an array formula with Ctrl+Shift+Enter in a range that is 100 rows long and one column wide):
=INDEX(B1:B7225,SMALL(IF(A1:A7225=4,ROW(A1:A7225)),ROW(INDIRECT("1:100"))))
Change the 4 to the desired search value (or a cell with the desired search value). You can get more/less than 100 results by changing the 100.
I just tested it against a non-array version that you fill down, e.g.,
=INDEX(B1:B7225,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=4),ROW(A1)))
and the array version is more than an order of magnitude faster.
Lets assume your search ID in in E4 and you want your search results to be in F4:F21. In F4 place the following formula and copy it down the maximum number row you think you might have.
=INDEX(B:B,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=E4),ROW(A1)))
I was going to put a caveat in about don't use full column references within the AGGREGATE function because it performs array calculations and will slow things down, but I believe Scott Craner's comment covered that.
Having said all that I believe using filters is the faster approach.
UPDATE
In order to avoid errors from being displayed, wrap the whole thing in an IFERROR function:
=IFERROR(INDEX(B:B,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=E4),ROW(A1))),"")
I am trying to come up with a formula in excel that allows me to have two separate criteria from two separate lists and then sum the total amount of values that meet those criteria. I can get the set of criteria to work, so
=COUNTIFS(Data!A:A,[#[Sub ID]] section allows me to see the amount of times a specific supID appears in column A. However, the second part where I am trying to see after that how many times any value from a particular list of values appears in a separate list, does not work.
Is there any way to make a formula count one list of values against another list of values without having to name each additional value in the formula.
I could do this if I wrote,
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,{"=apples","=pears","=bananas"[....]}))
But I don't want to have to write out each additional value, the list is too long. I just want to have the list in a column so I can reference it in the equation but it wont let me.
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B:B))
You are creating an iterative formula, You want to limit the last criterion to just the data set:
Mapping2!B2:B15
Then use SUMPRODUCT which will force the iteration:
=SUMPRODUCT(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B2:B15))
I have been working on a solution to this problem for a few hours now and I am basically no where except knowing that I don't know how to do it...So here goes.
I want to take the original data that I have in Excel that have 'code#s' for each 'category#'. With those 'code#s', I can look up the 'category#' name.
This has been so challenging because there are a varying number of categories for every 'title#'.
I have tried printing the 'category#' name next to 'title#', but it is seemingly impossible because Excel goes through every row in the original data and gives a True, False or #N/A instead of selecting and printing only the true statements without copying down a thousand rows. I want it to go through all the possibilities and only select the categories based on the criteria that they have the same 'title#' and their lookup code matches somewhere in the lookup table.
Thanks if you can offer any sort of help.
Here are some of the formulas I have tried:
IF(AND($M$5=TOP_TREND_CONTRIBUTORS!$W$2:$W$253,MATCH(TOP_TREND_CONTRIBUTORS!$A$2:$A$253,'Category Lookup'!$D$3:$D$30,0)<>"#N/A"),TOP_TREND_CONTRIBUTORS!$A$2:$A$253,FALSE)
....where M5, W:W is the 'title#', A:A is the code for the lookup-in that part I am trying to say that they are valid if the code registers in the lookup table and the 'title#s' are equal. The last part I am trying to get it to print the 'code#s' that are valid. But that only works when I drag the formula down all the rows.
Maybe I'm missing something, but I just tried to get from your original data and lookup table to the final result. I used VLOOKUP to put categories next to titles and then used pivot table to present the data in the way you wanted (after changing some settings of pivot table and fields). Is that what you need? (some words are in Polish, it doesn't matter).
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....