Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I don't know if it can be further simplified (there are some calculations made twice in the formula), but I came up with this for cell C18:</p> <pre><code>=INDEX(C$3:C$12,MATCH(9^99,IF(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18))=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18))),C$3:C$12))) </code></pre> <p>And this for cell B19:</p> <pre><code>=INDEX(B$3:B$12,MATCH(9^99,IF(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19))=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),B$3:B$12))) </code></pre> <hr> <p><strong>EDIT2:</strong> As barryhoudini pointed out, there was a mistake in there which his formula corrected. I edited the above two formulas. Otherwise, as he correctly mentioned, you can use this formula for C18 as well:</p> <pre><code>=LOOKUP(9^99,IF(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18))=MIN(IF($A$3:$A$12=$A18‌​,ABS($B$3:$B$12-$B18))),C$3:C$12)) </code></pre> <hr> <p>Notes: </p> <ol> <li><p>Those are array formulas and will work only with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Enter</kbd> instead of only <kbd>Enter</kbd>.</p></li> <li><p>The formula will get the last match in the table, in this case for A with measurement1 of 4.3, it will return 2.8, in cases where there's the same difference.</p></li> </ol> <p><strong>EDIT1:</strong> Okay, for consistency, I came up with this one to always get the higher match in B19:</p> <p><strong>EDIT3:</strong> And used <code>LOOKUP</code> instead of <code>INDEX</code>/<code>MATCH</code> for a little shorter formula and also fixed the first column issue.</p> <pre><code>=LOOKUP(9^99,IF(MAX(IF(ABS($C$3:$C$12-$C19)=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),C$3:C$12))=IF(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19))=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),C$3:C$12),IF(ABS($C$3:$C$12-$C19)=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),B$3:B$12))) </code></pre> <p>And this one for C18:</p> <pre><code>=LOOKUP(9^99,IF(MAX(IF(ABS($B$3:$B$12-$B18)=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),B$3:B$12))=IF(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18))=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),B$3:B$12),IF(ABS($B$3:$B$12-$B18)=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),C$3:C$12))) </code></pre> <p>For the lower match, B19:</p> <pre><code>=LOOKUP(9^99,IF(MIN(IF(ABS($C$3:$C$12-$C19)=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),C$3:C$12))=IF(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19))=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),C$3:C$12),IF(ABS($C$3:$C$12-$C19)=MIN(IF($A$3:$A$12=$A19,ABS($C$3:$C$12-$C19),999)),B$3:B$12))) </code></pre> <p>And for C18:</p> <pre><code>=LOOKUP(9^99,IF(MIN(IF(ABS($B$3:$B$12-$B18)=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),B$3:B$12))=IF(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18))=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),B$3:B$12),IF(ABS($B$3:$B$12-$B18)=MIN(IF($A$3:$A$12=$A18,ABS($B$3:$B$12-$B18),999)),C$3:C$12))) </code></pre> <hr> <p><strong>EDIT4:</strong> For two types:</p> <pre><code>=LOOKUP(9^99,IF(MAX(IF(ABS($C$3:$C$12-$C19)=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),C$3:C$12))=IF(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19))=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),C$3:C$12),IF(ABS($C$3:$C$12-$C19)=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),B$3:B$12))) </code></pre> <p>And this one for C18:</p> <pre><code>=LOOKUP(9^99,IF(MAX(IF(ABS($B$3:$B$12-$B18)=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),B$3:B$12))=IF(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18))=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),B$3:B$12),IF(ABS($B$3:$B$12-$B18)=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),C$3:C$12))) </code></pre> <p>For the lower match, B19:</p> <pre><code>=LOOKUP(9^99,IF(MIN(IF(ABS($C$3:$C$12-$C19)=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),C$3:C$12))=IF(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19))=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),C$3:C$12),IF(ABS($C$3:$C$12-$C19)=MIN(IF(($A$3:$A$12=$A19)*($D$3:$D$12=$D19),ABS($C$3:$C$12-$C19),999)),B$3:B$12))) </code></pre> <p>And for C18:</p> <pre><code>=LOOKUP(9^99,IF(MIN(IF(ABS($B$3:$B$12-$B18)=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),B$3:B$12))=IF(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18))=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),B$3:B$12),IF(ABS($B$3:$B$12-$B18)=MIN(IF(($A$3:$A$12=$A18)*($D$3:$D$12=$D18),ABS($B$3:$B$12-$B18),999)),C$3:C$12))) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload