Sunday 29 December 2019

Lining up sets of data in Excel (both with unique keys)


A related question asks how to line up two sets of data in Excel. I am struggling to figure out how to do this when you have values in both lists which don't exist in the other list. Ie: how would line up these lists?


Position    Occurrences
8 3
11 1
17 2
18 1

and another set of data has


Position    Occurrences
8 1
9 3
18 6

how can I line it up so that it's


Position    Occurrences     Position    Occurrences
8 3 8 1
9 3
11 1
17 2
18 1 18 6

You'll note that in this example we have Position's 11 and 17 which are in list 1 but not list 2. And Position 9 which is in list 2 but not list 1.



Answer



You need to create a master list containing all possible values (e.g. 1 to 20 in your case) and look for the corresponding values from the original list:
- fill numbers 1 - 20 in A2 to A21
- in column B put formula: =if(iserror(match(A2,,0)),"",A2)
- formula in column C: =iferror(vlookup(A2,,2,false),"")
- in columns D and E put the same formulas related for your second range
- in column F put this formula to check whether any of the ranges has value in the row to let you filtering out empty rows: =count(C2,D2)>0


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...