The Takeaway: You should avoid leaving hard-coded values in final formulas. However, you can and should use hard-coded values in incremental steps during development. This way you’re focusing on one functionality at a time. Once you’ve confirmed that the approach works, Replace those hard-coded values with derived, calculated or referenced values where possible.
Last time we added the first condition in our error checking IFS() routine: checking for low temperatures.
Now, as we saw last time this check works, so we've created the structure of our first error checking routine. However, we’ve now hard-coded our temperature range and error message into the formula. This means that if we wanted to change the temperature range we’d have to modify the table, the value and the error message in each formula they appeared in. It’s good practice to avoid this and replace it with either a derived value or a reference to a constant defined in a central place.
Let’s start with the temperature check. Because we already named the list of valid temperatures in our lookup table, Temperatures, we can easily derive the minimum temperature from that named range:
= T < MIN(Temperatures)
How about the error message? If we left this as text in the formula, then whenever we wanted to change the text of the error message we’d have to open this formula and change it directly, possibly in multiple places. With a complex formula such as this, we want to avoid that, since it just increases the risk of unintentionally changing something else.
We’ll approach this problem by creating a table of error messages, associating each with a name:
This means we can use the names in our functions, and are free to play with the wording of each error message without having to modify the function over again. As a bonus, we’ve also derived these error messages from the table ranges too, so even our error messages will automatically update if the lookup table changes.
Let’s make these two changes as our next incremental step in the lambda function, and check our tests:
There should be no changes in our test results, and that’s the case here. Great!
Now we're ready to add the rest of our error checking code.
Until next time, thanks for reading!
– Brendan
p.s. Enjoy this message? Read more at the Hyland Quality Systems website.
I'm Brendan Hyland. I help regulated facilities transform their software, spreadsheets, workflows and documents from time-consuming, deviation-invoking, regulatory burdens, to the competitive advantage they were meant to be. Join me every week as we take a few minutes to explore, design, test and improve the critical systems we use in our facilities.
Sometimes what was meant as a quick fix ends up growing into a hungry monster. The trouble is, the bigger it grows, the harder it is to walk away. Each workaround you add makes it more capable, more embedded in your process, and the ‘proper’ solution feels increasingly out of reach. But at what cost? Was this email forwarded to you? Subscribe Here! A few years ago I was working with a startup in a newly regulated industry. We had a strict requirement to report our inventory - raw ingredients,...
I’ve seen this pattern repeatedly: Instrument data is saved as an Excel or CSV. Data is then copied to a bare-bones spreadsheet with several columns of calculations or transformations. Results from the spreadsheet’s calculations are copied for use further down the data analysis pipeline. And I, the auditor, get handed a signed and dated pdf of the worksheet. Was this email forwarded to you? Subscribe Here! Why yes, M. Inspector, this spreadsheet was validated! Ok, they are rarely this bad - I...
Calling quality people everywhere! I've just released something I think you'll find useful. Over the past 20 years working in regulated environments, I've seen the same spreadsheet problems show up again and again: A quick Excel tool gets built to solve an immediate need. It works. Gets "validated" with a few hand calculations. Then gets reused and modified for different datasets or slightly different purposes. Eventually - sometimes months or years later - someone discovers an error. Or an...