I have an issue with a vlookup/index-match formula in excel 2010.
I have a table that contains duplicate values in the name column.
I have a table in another sheet that reference the name & amount from the first sheet.
in case a duplicate name exist in the original table, it should sum the amount.
For example, look at the pic below.
ABC is a duplicate name, and it's amount should be zero.
How can I use Vlookup/index-match formulas in order to display "0" in the result when I lookup the name ABC?
In the destination sheet, the name only appears once, hence I don't want to add another ABC to the dest table.
Thanks !
Roni.
VLOOKUP and or INDEX/MATCH will only return you one entry (the first match) - so you cannot use it for summing (unless in an array formula).
However, using SUMIFS (or in Excel 2003 and earlier SUMIF) will be just what you need: So In F2, you could write:
=SUMIFS($C$2:$C$6,$B$2:$B$6,E2)
Related
I want to write a dynamic excel condition to fetch some values based on the cell Contents.
My excel sheet contain 3 tabs. Home, tab_1 and tab_2 respectively. In the home tab, I have some text contents for selecting sheet and table.
In the tab_1 sheet, i have tables named as Table_1, Table_2,Table_3 and Table_4.
Now I want to get some elements from the table based on the text values.
Example: if the sheet name = Tab_1 and Table name = Table_1 then i will take the 2nd index values from Table_1 array in Tab_1 sheet.
My plan is to do dynamically using excel formula.
So i have tried to write the below logic to get 2nd index values.
INDEX(INDIRECT("'"&$B$2& "'!B1:F1"),2)
here it will take $B2 as Tab_1 . I am passing table value as "B1:F1".
Now i don't know how to get the matching array (instead of B1:F1) with the cell $B3 in the home sheet (Table_1).
Any suggestion or help ?
Finally after some research, I found the solution. We can use MATCH function to check the exact row name.
INDIRECT("'"&$B$2&"'!A1:F4)
This will search in the next tab (cell B2 text name ie: Tab_1 and table from A1 to F4 cells)
MATCH($B2,INDIRECT("'"&$B$2&"'!A1:F4),0)
This will search the exact name (from cell B3 text ie: Table_1) from the tab
So All together you can write below function:
INDEX(INDIRECT("'"&$B$2&"'!A1:F4),MATCH($B3,INDIRECT("'"&$B$2&"'!A1:F4),0),2)
I hope this solution will help you someone who facing for this kind of problems.
I have an Excel sheet with two columns. The first column holds names. I also have a list of names as text file, now added as second sheet.
For each row, I want to set the second cell to a fixed value if the value of the first cell is present in the list. Other rows should remain unchanged.
I was told to consider VLOOKUP but could not make up a formula.
I'm using Excel for Microsoft 365
first sheet:
column M is the one to be changed
second sheet:
The expected output would simple have entries in column M to be IN instead of OUT.
Try COUNTIF:
=IF(COUNTIF(List!A:A,A1),"IN","OUT")
You can do it with MATCH if the Second Sheet is in the same workbook. If it is in a separate workbook, it will still work, but only of the other workbook is open.
=IF( ISNUMBER( MATCH( A2,Sheet2!$A$2:$A$7, 0 ) ), "IN", "OUT" )
Alternatively, if you don't want to do VBA, you can pull the text file into a table in your workbook that is hidden into the data model and then reference it, but that is a long trip and can only be done on an installation that supports Power Query.
Formula would be somethin like
=VLOOKUP(K3,Table1,2)
Where Table1 is your look up, K3 is the value to look up (index) and 2 is the second column you want to return
[
I have 2 sheets in a workbook (Sheet1, Sheet2).
Sheet 2 contains a table (Named Table1) with 5 columns:
Takeaways
Household
Clothing
Fuel
Groceries
On sheet one, I have 2 columns:
Expense Name
Expense Total
Now, what I am trying to do is:
Set the range for the Expense Name (Range 1)
Set the range for the Expense Total (Range 2)
Compare Range 1 with the respective column in the table and only add up the values for matches
For example, in Range 1 (B6:B16):
BP
Caltex
McDonalds
KFC
In Range 2 (C6:C16):
300
400
200
150
Now, all I want to do is add up the values for the Takeaways (McDonalds, KFC) and exclude anything that DOES NOT match the criteria.
So my sum total will be all occurrences of Takeaways - provided they are listed in my table - 350 in this case.
But I cannot seem to get the formula to work.
I used these sources:
https://exceljet.net/excel-functions/excel-sumifs-function
Selecting a Specific Column of a Named Range for the SUMIF Function
and ended up with this formula:
=SUMIF($B$6:$B$16;Table1[Takeaways];C6:C16)
This source:
https://excelchamps.com/blog/sumif-sumifs-or-logic/
and ended up with this formula:
=SUM(SUMIFS(C6:C16;B6:B16;Table1[Takeaways]))
Both formulae return 0.
BUT, with BOTH of them, if I change Table1[Takeaways] to "McDonalds", then it correctly identifies every occurrence of the word "McDonalds" in Range 1.
EDIT:
I have updated the formulae above to match the images below.
This is the table that contains the references:
This table contains the data:
Formula:
Cell C4 (Next to Takeaways): =SUMIF($B$6:B$16;Table1[Takeaways];C6:C16)
Cell C5 (Next to Fuel): =SUM(SUMIFS(C6:C16;B6:B16;Table1[Fuel]))
It appears that ONLY BP is being detected in the formula.
This is a an output table when I use the formulae with a single cell reference and not a table or used range:
Formula:
Cell F4 (Next to BP): =SUMIF($B$6:B$16;"BP";C6:C16)
Cell F5 (Next to Caltex): =SUM(SUMIFS(C6:C16;B6:B16;"Caltex"))
Cell F6 (Next to McDonalds): =SUMIF($B$6:B$16;"McDonalds";C6:C16)
Cell F7 (Next to KFC): =SUM(SUMIFS(C6:C16;B6:B16;"KFC"))
If I understand correctly what you're trying to achieve, I think your setup is not right conceptually.
It looks like you're trying to track expenses, and each expense (or payee) is allocated to a category ("Takeaways", "Household" etc.). From a relational-model point of view, your second table (which defines the category for each expense/payee) should only have two columns (or variables): Expense Name and Expense Category.
The table you set up ('Sheet 2') uses the categories (i.e., possible values) as different columns (i.e., variables). But there's only variable, namely the "Expense Category", and the categories themselves are the possible values.
If you set it up like that, the problem changes: you can add a dependent column to your first table that shows the category for each payee (or "Expense Name"), using a VLOOKUP() from the second table.
You can then sum the expenses for all payees matching that category.
Note: I've created the illustration using LibreOffice Calc, so there might be some small differences, but the logic is the same.
Without seeing the data in L and K I can't give you a full answer - but likely it's to do with the way you're pulling your Array
Try something similar to this
=SUMPRODUCT(SUMIFS($L$11:$L$43,$K$11:$K$43,CHOOSE({1,2},Takeaways,"anything else you wanted to sum")))
Remember SUMIFS is for multiple criteria, so if you're only calculating one, you'll need =SUMPRODUCT(SUMIF(
The way the above works is with vertical vectors only, but changing your named ranges so the table of 2 columns is 2 named ranges instead should be okay - unless it's part of your requirements
Table 2 would become expense_Name and expense_Total etc
I was about to close this as a duplicate of my own question here but there is a bit of a difference in using a named range I think. However the logic behind this follows more or less the same approach.
Working further on my partial solution below I derived the following formula:
=SUMPRODUCT(COUNTIF(Table1[Takeaways];Range1)*Range2)
The COUNTIF() part counts the number of occurrences of the cell value in your table. Therefore make sure there are no duplicates in your table. If the value is present in the table the result of COUNTIF() will be 0. This way we create a matrix of 1's and 0's. By multiplying and the use of SUMPRODUCT() we force excel to perform matrix calculations and return the correct result.
Partial solution
I used the following formula:
=SUMPRODUCT(ISNUMBER(MATCH(Range1;Table1[Takeaways]))*Range2)
The formula does the following:
The MATCH()checks if the value in Range1 is present in your table and returns the position of the matching value in your table.
The ISNUMBER() checks if a match is found by checking if the MATCH() fucntion returned a number
Multiplying this with Range2 forces matrix calculation, using the SUMPRODUCT() function
EDIT:
This worked for a really limited sample. As soon as I added the fourth row to my data the formula stopped working as intended. See screenshot:
It took the first two values into the sum correctly, the fourth is not taken into account.
I have an excel document with two sheets, data and edu-plan. The sheet data has the following information:
The sheet edu-plan looks like this:
My question is: how do i create an excel formula that checks if the target group on the specific row in edu-plan! has the course name in question on the same row as the target group in sheet data!, i.e. if Sales and Sales course is on the same row in the sheet data!?
In reality, the data sheet as a couple of hundred rows and will change over time, so i am trying to develop a formula that i can apply easily on all rows/columns in edu-plan!.
The desired result in edu-plan would look like this:
A pivot table might be a good way to go.
If you would like to do it by formula, then you can just use a COUNTIFS
=IF(COUNTIFS(data!$A$2:$A$10,$A2,data!$B$2:$B$10,B$1),"X","")
A possible way to solve your issue with an array formula:
Write in B2 of sheet edu-plan
{=IFERROR(IF(MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)>0,"x",""),"")}
Since it is an array formula, you need to hit shift + ctr + enter.
Here is the formula broken down:
MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)
checks whether the combination of row header and column header is in the data table. MATCH returns the index of the found combination. Since we are not interested in the location, we only ask IF(MATCH > 0, "x", "") to write an "x" if a match was found. If MATCH finds nothing, it returns an error, which is why we add an IFERROR(VALUE, "") around the construct.
I have 3 sheets (ABC, DEF, GHI) where each sheet has 3 tables (TABLE1, TABLE2, TABLE3) and each table has 2 columns where 1st column consists of dates and 2nd column consists of data.
I defined "NAME"s for each table (ie. ABCTABLE1, ABCTABLE2, ABCTABLE3, DEFTABLE1, DEFTABLE2... etc.).
On another sheet, following 3 input cells are required to be filled by user (Sheet(B1), Table(B2) and Date(B3)). Let's assume they were filled by user as follows:
(B1): DEF
(B2): TABLE2
(B3): 05.01.2014
I also have 2 more cells where:
(B4): shows concatenated info of (B1) and (B2) with the formula (=B1&B2)
(ie. "DEFTABLE2" in our example in order to find which of the defined NAMEs should be used to bring up data in cell (B5).
(B5): shows data result, with the formula (=VLOOKUP(B3,B4,2,FALSE)
Although (B5) is expected to go to table NAME ("DEFTABLE2") and find date (05.01.2014) and choose 2nd column with data result of "65", it gives an error #N/A.
If I just enter manually the NAME as (=VLOOKUP(B3,DEFTABLE2,2,FALSE) by choosing from the defined NAMEs, data is coming properly. But if I try to pick that from a cell (B4) which contains the NAME as mentioned, it doesn't work. Any workarounds would be much appreciated?
Use =INDIRECT(B4) formula. It will return reference link from its text name.