When Nothing Matches, or Several Do
Real charts have holes, and sometimes they have two rows for the same thing. A Lookup has a setting for each case. One for when nothing matches, and one for when several rows match. This video shows both.
On this page
Chapters
Read the docs
Transcript
Show the full transcript
0:00 Intro
Real charts have holes, and sometimes they have two rows for the same thing. A Lookup has a setting for each case. One for when nothing matches, and one for when several rows match. This video shows both.
0:15 Nothing matches
Back at the postage scale. A twenty-five pound parcel goes on, and the chart stops at twenty. So the shop keeps a sign under the chart, oversized parcels, thirty dollars. When the chart has no answer, that's the price. In the Lookup it's one box. P one thousand four weighs twenty-five pounds, and no row goes that high. Under When nothing matches, use, type thirty. Now, instead of an empty field, the parcel shows thirty. Leaving the box empty and typing zero are different. Left empty, the field stays empty, so you can see at a glance that nothing matched. Set to zero, it shows zero, which adds up neatly in totals but looks like a real price. Pick the one that suits the chart.
0:57 Several rows match
Now the other problem. You're in a shop, and one item has two price tags on the shelf, twelve dollars and fourteen. Somebody added a new tag and never took the old one down. Which one do you pay? It depends on the shop's rule. A Lookup lets you set that rule. In a data table it looks like this. The Services table has two Express rows, row two at twelve dollars and row four at fourteen. Parcel P one thousand two is Express, so both rows match. By default the Lookup uses the first row, the one with the lowest row number, so twelve. The setting is called When several rows match, use, and it has seven choices. The first row gives twelve. The last row, the newest one added, gives fourteen. The total of their values, twenty-six. The average, thirteen. The smallest value, twelve. The largest, fourteen. Or nothing, treat it as no match. That last choice is a good alarm. With Nothing, treat it as no match, two Express rows count as no answer at all, so the parcel gets the value for no match, here zero. A zero fee stands out in a report, and tells you the price list has a duplicate to clean up. With a range, several means something narrower. With exact keys only, it's every row whose keys all match. With nearest lower or higher, it's only the rows tied at the nearest value, two rows that both start at fifty, say. With between, it's the rows tied on the latest start. With interpolation, it's rows sitting on the same point of the chart.
2:27 Setting it up
Both settings sit near the bottom of the Lookup. Open the Service Fee field. Under When several rows match, use, pick The last row, highest row number. Under When nothing matches, use, type zero. Save. Now duplicates take the newest row, and an unknown service shows zero.
2:49 Rules
Three rules to keep track of. Rule one: first and last mean the order rows were added, not any date on them. The last row is the one with the highest row number, the one added most recently. If you need the price in effect on a date, use a date range instead, as in video four. Rule two: a Number Lookup needs a number for no match. Type oversize into a Number Lookup's box, and saving stops with a message. A Text Lookup can use any words, like Not listed. Rule three: total and average only make sense for numbers. With a Number output, all seven choices are there. With Text, total and average drop out of the list. Smallest and largest still work on text, but they sort alphabetically. So that's the edge cases. When nothing matches, the value you choose, or empty. When several rows match, the first, the last, a total, an average, the smallest, the largest, or nothing at all, so duplicates stand out. Next up: testing a Lookup before you save it, and knowing exactly when it updates.
Also on Vimeo · the whole series on Vimeo