Help with a nested IF formula?

kordite23

New Member
Joined
Nov 19, 2017
Messages
4
Hi, I am running a test for parentage, comparing dna markers from possible parents. I am looking for a formula to be able to compare the numbers of the offspring against the parents, with the goal of getting an output of which father the offspring came from. Example for Offspring1 the output would be Father 2. If anyone would be able to help me it would be greatly appreciated.



Mother241, 255
Father 1256, 259
Father 2238, 261
Offspring1241, 261
Offspring2255, 256
Offspring3238, 255

<tbody>
</tbody>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Sorry one more question before I start on it, does it matter which number matches? As in can the left numbers only match the other left numbers? or can they match the number on the right as well. If so how do you determine which match gets preference?
 
Upvote 0
Either number can match left or right, just has to be one from the mother and one from one of the fathers. There isn't any preference as far as how they match.
 
Upvote 0
Hmm I have half a solution, I'm sure someone else here will be able to help out.

ABC
1Mother241255
2Father 1256259
3Father 2238261
4Offspring 1241261
5Offspring 2255256
6Offspring 3238255

<tbody>
</tbody>

With the data set out as above I came up with:

D4: =IF(MATCH(B4,$B$1:$C$1,0),IFERROR(INDEX($A$2:$A$3,MATCH(C4,$B$2:$B$3,0)),IFERROR(INDEX($A$2:$A$3,MATCH(C4,$C$2:$C$3,0)),"NO MATCH WITH FATHER")),IF(MATCH(C4,$B$1:$C$1,0),IFERROR(INDEX($A$2:$A$3,MATCH(B4,$B$2:$B$3,0)),IFERROR(INDEX($A$2:$A$3,MATCH(B4,$C$2:$C$3,0)),"NO MATCH WITH FATHER")),"NO MATCH WITH MOTHER"))

Which worked for offspring 1 and 2 but came up with #N/A on 3. I don't know why but I think it has something to do with the fact that the right hand number is the one which matches with the mother and my logic must be jumbled up in the formula. I thought I stepped through it correctly but must have gotten lost somewhere.
 
Upvote 0
I've fixed up my formula and should work now:

=IF(NOT(ISERROR(MATCH(B6,$B$1:$C$1,0))),IFERROR(INDEX($A$2:$A$3,MATCH(C6,$B$2:$B$3,0)),IFERROR(INDEX($A$2:$A$3,MATCH(C6,$C$2:$C$3,0)),"NO MATCH WITH FATHER")),IF(NOT(ISERROR(MATCH(C6,$B$1:$C$1,0))),IFERROR(INDEX($A$2:$A$3,MATCH(B6,$B$2:$B$3,0)),IFERROR(INDEX($A$2:$A$3,MATCH(B6,$C$2:$C$3,0)),"NO MATCH WITH FATHER")),"NO MATCH WITH MOTHER"))

Let me know how it goes for you.
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top