Arranging data in Excel - 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.

Related

How can I automate these formulas?

Hello,
I need to automate these formula.
Wheat 2 USA minus wheat 1 USA, Wheat 2 Brazil minus wheat 1 Brazil, Wheat 2 Canada minus wheat 1 Canada, Wheat 2 Argentina minus wheat 1 Argentina and so on for every product and taking into account corresponding regions and week numbers.
Barley 2 USA minus barley 1 USA, Barley 2 Brazil minus barley 1 Brazil, Barley 2 Canada minus barley 1 Canada ...
A formula should work in such a way that when I populate it, it understands the logic and make a calculation.
Use LOOKUP to find previous value of current product:
=IFERROR(C2-LOOKUP(2,1/($A$1:A1=A2),$C$1:C1),"")
or so if the Input number column matters:
=IFERROR(C2-LOOKUP(2,1/(($A$1:A1=A2)*($B$1:B1=(B2-1))),$C$1:C1),"")
First: I like #basic's solution much better! I keep forgetting that =LOOKUP(LargerThanAll,Nums,Values) returns the value for the highest num!
That said, here's another way:
First, put your cursor on the top line and Insert - Table, making sure you check the "My table has headers" checkbox in the dialog box that appears.
Now, in addition to having it formatted, there are formula benefits.
Keeping with your example where the B2 = "Product",
Change F2 to "Product|Number" to create a new column
Change F3 to =[#Product]&"|"&[#[Input Number]] (Because you're using tables, you can use column names rather than cell references, [#ColumnName] is the column value for the current row, it will use that formula for the entire column, and the formula is stored once instead of once per row!)
Change G2 to "PrevRow"
Change G3 to =MATCH([#Product]&"|"&([#[Input Number]]-1),[Product|Number],0) (you now have the table row number for the previous value
Change E3 to =IF(ISNUMBER([#PrevRow]),[#Quantity]-INDEX([Quantity],[#PrevRow]),"")
Hide columns F and G. (Or fold their functionality into your Volume's formula so your volume formula doesn't need them and delete them.)

Excel - Data Validation blank items in the list, dependency list

We are looking to create a dependent list based on 2 sheets as described below.
Sheet 1:
col A: Need to choose a value from drop down referring to col country in sheet 2
col B: Need to country corresponding cities available in sheet2
Sheet 2:
col Country: USA UK India Australia
col USA cities: Boston Chicago Seattle SanDiego
col UK cities: London Manchester Edinburg Glasglow
col India cities: Mumbai Delhi Kochin
col Aus Cities: Victoria Melbourne Sydney
Typical example:
If we choose the country from drop down as USA in colA (sheet1), then the colB (sheet1) needs to show all the USA cities from "col USA cities".
I have tried using Blank Values in Excel Data Validation drop down list with data validation for col B as =Indirect($A2 & "list") (after naming the cities as lists such as USAlist, UKlist etc) but didn't help.
Also, any idea how to solve the blanks shown by the list in this scenarios?

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

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<>"")

How to find the correct Matrices with INDEX/MATCH

I have 10 different matrices, each matrices represents a region. For example: Canada, South West, Florida, etc. Within each matrix is a list of products in the rows and a list of products in the columns. All of the matrices have been created as tables in excel with the names being their region names. The values in the matrix represent the discount given to a customer if they purchase BOTH of those products in that region (The matrices are on a different tab from the lookup data). For example, in the matrix below, if a customer in Canada purchases Doll and Energy Drink, they will be given a $10 Discount.
How would you go about creating an equation in column D of the example below that returns that dollar value based on all three of these criteria: correct matrix, correct product (row), correct product (column). I do apologize for now posting an INDEX/MATCH equation to work from but I'm rather new to Excel and am not sure where to start. I will reply promptly to any questions you may have, Thanks!
Canada Matrix Example (Table Name = Canada)
Energy Drink Phone Bag
Doll $10 $20 $15
Hat $5 $13 $17
Stapler $8 $14 $23
Data Sheet
Column A Column B Column C Column D (Output)
Canada Doll Energy Drink Equation (=$10)
Florida Hat Phone Equation
South West Stapler Phone Equation
Canada Hat Notepad Equation (=$14)
The following INDEX/MATCH formula that will work within the single Canada array provided in the sample.
=INDEX($B$2:$D$4,MATCH($B9,$A$2:$A$4,0),MATCH($C9,$B$1:$D$1,0))
You could then copy this into several layers of IF statements which point each copy of the INDEX/MATCH formula to the appropriate Region array in the worksheet.
As long as Column B is always the Row, and Column C is always the Column, then this should work fine. In the case of the provided sample, the last transaction (Canada, Hat, Stapler, return 14) does not work because the reference array does not have a Stapler column. I assume the working file has a more expansive array.
This worked for me:
As long as your tables are named ranges it wouldn't matter where they're located.
I broke up the logic into a number of columns but you could just as easily combine them into a single formula.
The key is that:
INDEX(TableRangeHere, 1, 0)
INDEX(TableRangeHere, 0, 1)
return the entire first row and column respectively of the named range
In case anyone wants to see the answer I came up with. It involves a series of INDEX/CHOOSE/VLOOKUP/MATCH functions. The Regions are simply the names I gave the matrices
=INDEX(CHOOSE(VLOOKUP(B:B,xref!L:M,2,0),Canada[#All],Central[#All],Florida[#All],GreatLakes[#All],MidAtlantic[#All],NorthEast[#All],NorthWest[#All],SouthCentral[#All],SouthEast[#All],SouthWest[#All]),MATCH(F2,CHOOSE(VLOOKUP(B:B,xref!L:M,2,0),Canada[[#All],[MODEL]],Central[[#All],[MODEL]],Florida[[#All],[MODEL]],GreatLakes[[#All],[MODEL]],MidAtlantic[[#All],[MODEL]],NorthEast[[#All],[MODEL]],NorthWest[[#All],[MODEL]],SouthCentral[[#All],[MODEL]],SouthEast[[#All],[MODEL]],SouthWest[[#All],[MODEL]]),0),MATCH(E2,CHOOSE(VLOOKUP(B:B,xref!L:M,2,0),Canada[#Headers],Central[#Headers],Florida[#Headers],GreatLakes[#Headers],MidAtlantic[#Headers],NorthEast[#Headers],NorthWest[#Headers],SouthCentral[#Headers],SouthEast[#Headers],SouthWest[#Headers]),0))

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Resources