Excel: Matching Data in Excel. Writing an IF statement by dragging instead of manually inputting - excel

I have two sheets. Both sheets contains two columns with Countries and Price #s. The first sheet does not have info for the Price # but the second does.
Sheet 1:
Country|Price #
Canada | Null
Brazil | Null
Spain | Null
Canada | Null
Sheet 2:
Country|Price #
Canada | 1
Spain | 2
Brazil | 3
Austria | 4
Goal: I want to fill out the Null values in sheet 1 with the corresponding numbers in sheet two. For example a 1 for Canada, 3 for Brazil, etc.
If I didn't have much data, this would be an easy IF statement in the Null cell. For example
' =IF(B2="Canada",1, IF(B2="Spain",2,IF(B2="Brazil",3,4)))
Problem is that my data contains over 50 countries so it would be tedious to write this formula. Is there a way to use the drag feature in Excel to do this? Also open to not using an IF statement.

Or you can use SUMPRODUCTif you need return numbers only:
=SUMPRODUCT(--(D1=$A$1:$A$4)*$B$1:$B$4)

Sheet2:
Sheet formula Pict 1:
Sheet Formula Pict 2:
Here the formula to be copied, choose as your need:
=filter(if(C1:C="",vlookup(B1:B,Sheet2!A1:B,2,false),""),B1:B<>"")
or
=filter(vlookup(B1:B,Sheet2!A1:B,2,false),B1:B<>"")

Related

Arranging data in Excel

I have data in excel. I need help, to arrange it.
part of the data
I need to write for each product all of the countries where it is sold, separate the countries with " | ", For Example: if a certain product is sold in SPAIN, UK, FRANCE, BRAZIL and RUSSIA the row of this column will show: SPAIN | UK | FRANCE | BRAZIL | RUSSIA.
It's need to be in the same column....
Here is one easy way you could do it if you want to see what you're doing.
Fill column C and D, result will be in D. Column B needs to be sorted.
A
B
C
D
1
Country
Product Code Central
Country List
Formatted List
2
UKRAINE
194
=IF(B2=B1;C1&"|"&A2;A2)
=IF(B3<>B2;C2;"")
If you have a version of Excel that understands both TEXTJOIN and FILTER (the former is the most recent, available in Excel 365) the formula below will return the result you describe.
=TEXTJOIN("|",TRUE,(FILTER(A$2:A$11,B$2:B$11=D2,"None")))
Here A2:A11 has the country names, B2:B11 the product numbers and D2 any value from B2:B11.

Excel Formula - Return unique count of range based on multiple criteria from different tables

I have three tables: Parties, Document Detail and Document. (Note, they are not table formatted, so all references are based on cell and sheet location, not table aliases)
I want to return a unique count of the parties in each Document using an Excel Formula. My problem is, I would usually use a =COUNTIFS() formula for this, which would be something like the following, which I would put in B2 of Sheet 3 (Document table):
=COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,Sheet1!A2)
But this will only return the count of one criteria at a time, not a count checking for all values of the parties table per document. I understand it should be able to be done with an array formula, but I can't figure it out. Bonus points if someone can figure out how to do it with a non-array formula!
Sheet1 - Parties Table
A
1|Parties |
+-----------------+
2|Education Officer|
3|Elder |
4|Family Support |
5|Interpreter |
Sheet2 - Document Detail Table
A B
1 |Doc ID | Party |
+-------+-----------------+
2 |FID0001|Education Officer|
3 |FID0001|Elder |
4 |FID0001|Education Officer|
5 |FID0001| |
6 |FID0001| |
7 |FID0002|Elder |
8 |FID0002|Interpreter |
9 |FID0002|Family Support |
10|FID0002| |
Sheet3 - (Desired Result) - Document Table
A B
1|Doc ID |Party Count|
+-------+-----------+
2|FID0001| 2 |
3|FID0002| 3 |
TL:DR
What combination of Excel formulas can I use to return the number of unique parties referenced in each document?
Based on this answer by Barry Houdini and expanded to include the DocID criteria
Put a helper column on Sheet2, lets say in colum C
=IFERROR(1/COUNTIFS($B:$B,$B:$B,$A:$A,$A:$A),0)
and copy down for all data rows
Then, in Sheet3 Party Count Formula is
=SUMIFS(Sheet2!$C:$C,Sheet2!$A:$A,$A:$A)
The non-Implicit Intersection versions
Sheet2 cell C1
=IFERROR(1/COUNTIFS($B:$B,$B1,$A:$A,$A1),0)
Sheet3 cell B2
=SUMIFS(Sheet2!$C:$C,Sheet2!$A:$A,$A2)

Excel Formula or Macro to get the consolidated list from two tables

Question:
Table 1 is as follows.
Name | Hours
john | 12
mark | 20
john | 10
mark | 10
Table 2 is as follows.
Name | Hours
john | 40
mark | 30
These 2 tables are in two diffent workbooks. The Data I need is as follows.
Step 1: From Table 1 I need to consolidate the Column 'Name' and should get the SUm of Column 'Hours'. (i.e) it should be populated as follows.
Table 3
Name | Hours
john | 22
mark | 30
Step 2: Once the above step is achieved I should compare the Column 'Hours' in Table 2 & Table 3 and should populated the result as true or false..
Try this formula:
=IF(SUMIF([Workbook1]Sheet1!$A$1:$B$4;A1,[Workbook1]Sheet1!$B$1:$B$4)=B1,"true","false")
It assumes that Table1 is in Workbook1, Sheet1 in range A1:B4.
I also assumed that Table2 locates in A1:B2 range. Now it's enough to place above formula in C1 cell next to Table2 and drag it down.
Create two pivot tables for both tables and compare accordingly. Then,
=GETPIVOTDATA("Hours",$A$2,"Name",A3)=GETPIVOTDATA("Hours",$A$8,"Name",A9)

Excel IF Formula 3

I have a sheet with rows of data that I want to copy to a different sheet if the name in column a equals a certain value. For example:
A | B | C
Name | Color | Amount
Sue | Blue | $400
Joe | Green | $1000
Sheet Sue needs to bring columns B and C from Sue's records to it's worksheet if column a equals Sue
Sheet Joe needs to bring columns B and C from Joe's records to it's worksheet if column a equals Joe
and so on and so forth...
Can anyone help!?
Well, if you don't have too much data you can do this with array formulas.
Set up your main sheet (assuming it's Sheet1) with named ranges. Your A2:A100 name it Name, B2:B100, name it Color, and C2:C100 name it Amount. (Adjust the range as necessary)
Then, in each of the people's sheets, have header rows called Name, Color, and Amount. Then you can use this formula (entered with CTRL+SHIFT+ENTER):
=INDEX(INDIRECT(A$1),SMALL(IF(INDIRECT($A$1)=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255),ROW(INDIRECT($A$1))-ROW(Sheet1!A$2)+1),ROWS(Sheet1!$A$2:A2)))
Wrap IFERROR([formula],"") to hide the #NUM errors when you reach the end of the data.

Excel multi column lookup

I am unsure how to Google this one. I have a table that looks like the below
Last Name | First Name | Team A | Team B | Team C
Smith | John | X | |
Doe | Jane | | X |
This would be the main sheet. The names in this sheet are divided into other sheet depending on what department they are in. Those sheets are setup in the same formats with the same columns. If the people in the main sheet are marked with an X in one of the columns I would like that same column marked in marked in the department sheets.
Your best bet might be to create a hidden column A where the value is a combination of column B and column C on all of your tabs. You could then use the standard VLOOKUP wrapped in an IFERROR clause.
For example,
=IFERROR(VLOOKUP(A1,Sheet1!A:F,3,False),"")
The IFERROR handles the instance that you may have a name on a sub tab not on the main tab. It returns blank instead of #N/A. The VLOOKUP is checking the value in A1 to what is in A1 on your main tab. A1 would be the combination of First and Last. The VLOOKUP would need to be in each of your team columns shifting the column returned number in each VLOOKUP.

Resources