So I have a column of numbers I want to sum. Each number is associated with a value on a lookup table. I need to find what values I want to use to sum based on the lookup table itself.
Basically, I need to sum everything in column I based on whether the entry in column J matches a MFG in column M that matches a reference number in column O. I have tried multiple iterations of SumProduct and array formulas, and have had no luck getting it to work. Everything I've read online about summing based on multiple criteria only works if you know ahead of time how many conditions you have to match; I don't have that information.
This will iterated through the second table and if the Ref Num match the input in M16 then it returns the SUMIF() value of MFG from the first table and sums them all together:
=SUMPRODUCT((M16=$O$7:$O$12)*SUMIF(J:J,$M$7:$M$12,I:I))
Notice that the references to Table 2 are limited to the actual data, while the references to table 1 can be full column references. That has to do with how the formula will iterate. As it literally will iterate through the second table we want to limit the number of iterations to the data set itself. While the SUMIF() formula is already optimized and has no detriment to full column references.
Related
I'm using the filter formula to return a list of results. The length of rows of the list is variable.
For each returned value I need to apply a new formula. I would like to know if I can extend this formula automatically all rows based on the length of the list.
A simple example: On cells A1:B100 I have a list of values. On Cell D1 I have this formula =FILTER(A2:A10;B2:B10="Filter")
The result will be a list in Colum D that can have 1 row and upto 100.
In Column E I need to have this formula D1*10. This should extend to the rows below dynamicaly based on the number of rows returned on the Filter formula
Any ideas if this can be done automatically?
What I'm doing is quite more complex than this example since I'm filtering a table that is in a different workbook that is custom data type and the number of rows will vary from about 10 to over 9.000
Use the spilled range operator # after the cell in question:
=D1#*10
A simple example as below:
Column A is the list containing all data
Column B is the list of all unique data in Column A without duplicates
Column C will be the number of duplicates for each item in Column B from Column A
How to write a easy formula for cells in Column C to sum each item in Column B from Column A?
I used =sum(lookup($a$1:$a$10=$B$1)) for C1 but received: too few arguments for this function.
A simple countif() should suffice unless I'm misunderstanding..
=COUNTIF($A$1:$A$10,B1)
Count if returns the number of times the second argument is found in the first argument (which is a range.)
With a PivotTable may be even simpler:
The unique list is created as part of constructing the PivotTable, and is sorted alphabetically. A Total may also be automatic, for control purposes.
I need to be able to find the row number of the row where matching criteria from A1 is equal or greater than values in column C and lesser or equal than values in column D
I can use INDEX and MATCH combo but not sure if this is something I should use for multiple criteria matching.
Any help or suggestions are highly appreciated.
I would not use MATCH to get the row number since you have multiple criteria. I would still use INDEX however to get the value of the row in E once the proper row number was discovered.
So instead of MATCH I would use an array formula using an IF statement that contained multiple criteria. Now note that array formulas need to be entered using ctrl + shift + enter. The IF statement would look like this:
=IF((A1>=C:C)*(A1<=D:D),ROW(A:A),"")
Note: I did not use the AND formula here because that cannot take in arrays. But since booleans are just 1's or 0's in Excel, multiplying the criteria works just fine.
This now gives us an array containing only blanks and valid row numbers. Such that if rows 5 and 7 were both valid the array would look like:
{"","","","",5,"",7,"",...}
Now if we encapsulate that IF statement with a SMALL we can get whatever valid row we want. In this case since we just want the first valid row we can use:
=SMALL(IF((A1>=C:C)*(A1<=D:D),ROW(A:A),""),1)
Which if the first valid row is 5 then that will return 5. Incrementing the K value of the SMALL formula will allow you to grab the 2nd, 3rd, etc valid row.
Now of course since we have the row number a simple INDEX will get us the value in column E:
=INDEX(E:E,SMALL(IF((A1>=C:C)*(A1<=D:D),ROW(A:A),""),1))
If you need to match more than one column value to retrieve a row number, that is, if two or more columns together create a unique ID you can use an array formula with MATCH as below:
MATCH(1,(A:A=J1)*(B:B=K1)*(C:C=L1),0)
where A, B, C contain the column array to be matched to retrieve the unique row number corresponding to the value in J1, K1, L1 respectively.
For a step-by-step guide, Christian Pedersen's Explainer
Imagine a 100x100 table. I have to find a given value in the first column. Then I have to check the row contains that given value, and I have to find the column where the value is 1 (every row has only one cell with value 1), and I need the first row's value of that column. I've tried several lookup functions (vlookup, hlookup, index match match, etc). No results. Is it possible using only functions and no VBA at all?
I'd prefer to use INDEX rather than INDIRECT, it's not volatile and it's more robust in dealing with added rows or columns than "hardcoded" values like "B" and "D", so assuming data in A1:Z100 you can use this formula for the match, assuming a search value of "x"
=MATCH(1,INDEX(B2:Z100,MATCH("x",A2:A100,0),0),0)
...and you can add an extra INDEX function to retrieve the first row value for that column
=INDEX(B1:Z1,MATCH(1,INDEX(B2:Z100,MATCH("x",A2:A100,0),0),0))
I have this data table and i want another result table. when I write name of state ,result table can show all of company with data1,data2 and data3.I trying use vlookup but because there are merged cells the formula just show first row.
how can I fix problem?
If I'm understanding correctly, you want to set up a lookup range so that when you enter a particular state, you can see the data for all the companies that have data in that state. Here is one way to do that.
The first thing you would need to do is set up three columns to the left of the original table:
The first column holds the name of the state associated with each row of data
The second is an index that counts off the number of data rows in each state
The third combines the first two columns to produce a unique key value for each row in the table.
All the values in these three columns can be assigned by formula. The picture below shows the formulas for the first row of cells A9:C9, which are then copied down through row 27.
The next step is to lay out the new table, which is in cells Q8:U27 in my example.
There are several thing to note about the setup. First, the state that will be displayed is entered in cell Q9, which I've highlighted in yellow. To the left of the table, in column P, I've entered item numbers from 1 to 19, which will be needed to construct the key values for the lookups. The lookup formulas themselves are in cells R9:U27; in the picture, the formulas for the first row (R9:U9) are shown (they are then copied down through row 27).
It's worth taking a moment to look more closely at one of the lookups. Here is the formula for the first company name in cell `R9'.
=IFERROR(VLOOKUP($Q$9&$P9,$C$9:$N$27,4,0),"")
Looking at each of the arguments of the VLOOKUP in turn, $Q$9&$P9 concatenates the state name in cell Q9 with the item number (1 in this case), yielding the lookup value 'California1'. The lookup table is defined as the range $C$9:$N$27 - column C of that range is what the lookup value is matched against. The third argument is the column from which to return a value if the lookup is a match. The number 4 here corresponds with the company name column of the original table. Finally, the last argument is 0 (or equivalently, FALSE) indicating an exact match is required.
Finally, the VLOOKUP function is wrapped inside IFERROR. This catches the #N/A that would otherwise be returned when no match is found, replacing it with an empty string ("").