Reading Between the Lines
Some charts only list a few points, and your number falls between them. A chart lists the cost at five hundred dollars and at a thousand, but your parcel is worth seven fifty. Interpolation reads between the two lines, the way you would with a ruler. This video shows how, with one key and with two.
On this page
Chapters
Read the docs
Transcript
Show the full transcript
0:00 Intro
Some charts only list a few points, and your number falls between them. A chart lists the cost at five hundred dollars and at a thousand, but your parcel is worth seven fifty. Interpolation reads between the two lines, the way you would with a ruler. This video shows how, with one key and with two.
0:19 One key
Picture a road with mile markers. At marker five hundred, a sign says four fifty. At marker one thousand, it says seven dollars. You're standing at seven fifty, exactly halfway between. So your price is halfway between, too. Halfway from four fifty to seven is five seventy-five.
0:38 In your app
In a data table, the signs are rows. The Insurance Rates table has a declared value and a cost: a hundred, five hundred, a thousand and five thousand. Parcel P one thousand two is declared at seven hundred and fifty dollars. The rows right below and right above are five hundred and one thousand. Seven fifty is halfway between them, so the insurance is halfway between four fifty and seven, five seventy-five. It isn't always halfway. P one thousand three is declared at two thousand. That's between one thousand and five thousand, a quarter of the way along. So the cost is a quarter of the way from seven to twenty. Thirteen dollars apart, a quarter of that is three twenty-five, so ten twenty-five. And when a value sits exactly on a row, like P one thousand five at one hundred dollars, there's nothing to read between. Now the two parcels outside the chart. P one thousand one is declared at fifty dollars, below the first row. P one thousand four is declared at six thousand, above the last. There's nothing to read between, so both stay empty. Turn on the switch called Use the nearest end row outside the table. Below the first row, the Lookup uses the first row, one fifty. Above the last row, it uses the last row, twenty dollars.
2:06 Two keys
Some charts have two ways in, like distance and weight. Picture a city map with a price at four street corners. Fifty miles and five pounds, six dollars. Two hundred miles and five pounds, ten. Fifty miles and twenty pounds, twelve. Two hundred miles and twenty pounds, twenty. Your parcel is a hundred and twenty-five miles and ten pounds, somewhere inside that block. Its price is blended from all four corners. The closer a corner is, the more it counts. Here's how the blend works, in two easy steps. First, along the distance. A hundred and twenty-five miles is halfway from fifty to two hundred. On the five pound street, halfway from six to ten is eight. On the twenty pound street, halfway from twelve to twenty is sixteen. Then along the weight. Ten pounds is a third of the way from five to twenty. A third of the way from eight to sixteen is ten sixty-seven. In a data table, the grid is a table called Delivery Grid. Nine rows, one for each corner: three distances, fifty, two hundred and five hundred, by three weights, five, twenty and fifty. For P one thousand two, the Lookup finds the four corner rows around it, and blends them, ten sixty-seven. P one thousand four is six hundred miles away, past the last distance on the grid. With Use the nearest end row turned on, it uses the five hundred mile column. Then it reads down that column. Twenty-five pounds is a sixth of the way from twenty to fifty, so a sixth of the way from thirty to fifty, thirty-three thirty-three.
3:45 Setting it up
On the Parcels table, add a Lookup called Delivery Charge. Look up the value in Delivery Grid. Return this field, Charge. Under Range match, pick Interpolate between rows. For the column, Distance, against this record's Distance. Under Second key to interpolate on, pick Weight, against this record's Weight. Turn on Use the nearest end row outside the table. The output is a number, with two decimal places. Save.
4:14 Rules
Three rules to keep track of. Rule one: interpolation needs numbers. The value it returns is always a number, so when you pick Interpolate, Text disappears from the output types. The columns you interpolate on must hold numbers, dates or times. Rule two: a two key grid needs every corner. If someone deletes the row for two hundred miles and twenty pounds, the parcels inside that block have only three corners. The Lookup can't blend three, so nothing matches. Fill in every combination. Rule three: outside the table, it's the switch or nothing. With Use the nearest end row off, a value past either end stays empty, or gets your value for no match. Turn it on, and the end rows are used instead. So that's interpolation. Between two rows, a straight line. Between four corners, a blend. And past the ends, the nearest end row, if you turn it on. Next up: what happens when nothing matches, and when several rows do.
Also on Vimeo · the whole series on Vimeo