An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

One way of looking at the problem is to treat the systolic and diastolic readings as orthogonal axes (i.e. like an XY plot). The closest reading is one that minimizes the

distancebetween the ideal value and the set of actual readings.You can use the Pythagorean theorem to find that distance as SQRT((Systolic-120)^2 + (Diastolic-80)^2). Since the request is to find the closest reading, you can eliminate the SQRT bit from the problem and just look for the minimum sum of squares--it will also be the minimum square root::

=MIN((Systolic-120)^2 + (Diastolic-80)^2) Systolic and Diastolic are a range of values

The matching blood pressure reading will then be:

=INDEX(B2:B8,MATCH(MIN((B2

The MIN and INDEX formulas above are regrettably array formulas. I believe it will be necessary to choose one of the following evils:

a. Use a VBA user-defined function to hide all the nastiness and return the closest reading

b. Use an array-entered formula as suggested above

c. Use an auxiliary column (just one) that contains the sum of squares for each reading. If you put up with the auxiliary column, then a regular formula can be used like the following:

=INDEX(B2:B8,MATCH(MIN(D2:

The auxiliary column (D2:D8) contains a formula like:

=(B2-120)^2+(C2-80)^2

Brad

EE1-least-squares.xlsx