The formula in cell B3 below computes a string that describes the location of a point in a Cartesian space. The X and Y coordinates of the point are contained in cells B1 and B2, respectively.
The location is constrained to be in a rectangular area as shown in the image below, that is, having an X value between 0 and 9, inclusive, and having a Y value also between 0 and 9, inclusive.
Given values in cells B1 and B2 for the X and Y coordinates of a point in this Cartesian space, the formula will provide one of five strings: “Values out of range,” “Lower left quadrant,” “Upper left quadrant,” “Lower right quadrant,” or “Upper right quadrant.”
The image below shows Formula Forge’s central panel with cell B3 selected. The nested IF structure of the formula in that cell is clearly shown in the Tree View.
The image below shows Formula Forge’s central and right panels with the second argument of the last IF function (“Lower right quadrant”) having been highlighted by clicking that argument in the Tree View. This click highlights the argument in all views. It also makes a list in the Logic Regions area of the logical test argument, along with the value, of every IF function above the cell’s formula in the Tree View. In this example, one can see that the first logical test, AND(B1 >= 0, B1 <= 9, B2 >= 0, B2 <= 9), which ensures that X and Y are in range, is true. Likewise, one can see if the point is in the lower right quadrant because B1 <= 4 is false and B2 <= 4 is true.
This is very handy, but it would be handier if the texts of the logical tests were replaced with descriptive strings. FormulaForge provides the capability to do this. In the image below of the full FormulaForge window, the Scrapbook area in the upper portion of the left panel assigns a descriptive name to each important logical test.
These names are the following:
“in_range” is AND(B1 >= 0, B1 <= 9, B2 >= 0, B2 <= 9)
“left_half” is B1 <= 4
“lower_half” is B2 <= 4
In the image below, these names have replaced the text of the various logical tests in all views in the central panel. With these descriptive names, it is much easier to understand the logical tests in the entire formula. Furthermore, the Logical Regions area in the upper right panel now shows the value of all the logical tests required for the formula to evaluate to “Lower right quadrant”: these are that in_range is true, left_half is false, and lower_half is true.
Some formulas contain nested IF structures that are much more complicated than this example. FormulaForge provides a powerful tool that helps Excel users construct, understand, and debug these formulas.
]]>The reasons for this are threefold. First, if a formula is complicated, then it may contain more characters than will fit into Excel’s formula bar. This makes it very hard to see the entire formula in a glance. Second, Excel depends on parentheses to specify the order of computations. Deeply nested parentheses also make it difficult for the user to comprehend the structure of a formula. Finally, Excel represents a formula as a single line of text. Virtually all software text editors make code much easier to read by using vertical space, tabs, and colors to reveal its structure.
Because of these issues, many Excel formula developers choose not to develop single monolithic formulas. Instead, they change what would be a complicated single formula into a simpler master formula that refers to other cells that compute intermediate values. These cells, in turn, may refer to yet other cells that compute intermediate values for them, and so on. The simpler formulas in each of these intermediate cells are essentially subexpressions of the complicated formula that the formula developer chose not to build in a single cell.
The image below shows a spreadsheet that contains three ranges.
The image below shows the same spreadsheet but with formulas shown.
One can see the tradeoffs between using intermediate values and having a singlecell formula that refers only to the starting input values. The intermediate value approach has a simpler formula in the cell that computes the final value but has several disadvantages. First, the resulting spreadsheet has many more cells than necessary. These extra cells may cause the sheet(s) containing the intermediate values to become too large to fit on small screens, such as those on laptops or mobile devices. Second, the extra cells clutter up the spreadsheet, making it hard for the reader to distinguish between cells holding values of interest and cells holding intermediate values that have no reason to exist other than to provide feeder values for other cells. One can tell whether a cell contains a feeder value for another cell by using Excel’s auditing tools to look for dependents, but doing this does not distinguish between cells that have independent interest (e.g., row totals) and those that do not. Furthermore, using Excel’s auditing tools can be problematic if a dependent is on a different sheet than the intermediatevalue cell: Excel does not point to specific cells on other sheets, but simply provides a graphical representation that the cell is on another sheet. A final disadvantage of the intermediate value approach is that it does not work for array formulas, which cannot be broken up into intermediate computations.
The singlecell formula approach allows for spreadsheets without extraneous cells, but it makes it harder to construct and debug formulas. FormulaForge solves this problem. Specifically, it allows Excel users to build and debug a complicated formula in a single cell without the disadvantages of using intermediate cells. It corrects the problems that occur when using Excel alone by
Formula Forge’s Tree View overcomes all the of the disadvantages of intermediate cells described above while at the same time maintaining the intermediate cell advantage of showing intermediate values. The image below shows the Tree View for our sample formula.
The example in this blog entry is very simple but illustrates the value of being able to construct a complicated formula in a single cell. As the complexity of a formula increases, the value of FormulaForge becomes more and more evident.
]]>FormulaForge provides much more help for doing this than does Excel alone. First, FormulaForge makes it easy to find all subexpressions in a formula: each subexpression is represented by an element in the Tree View, with the top element representing the entire formula. Without FormulaForge, one generally needs to painstakingly count parentheses in Excel’s formula bar to find where subexpressions begin and end.
Second, FormulaForge shows (in red) the values of most subexpressions next to the elements that represent them in the Tree View. The only values not shown in red are those for constants, for which the value is already visible, and those for arrays (such as multicell ranges), for which the existence of too many values to display is indicated by an ellipsis (…).
If a formula produces the wrong value, then the incorrect value appears in red next to its top element in the Tree View. To find the cause of this error, it pays to start by examining the children of the top element to see if one (or more) has an incorrect or suspicious value next to it. (If not, the problem is with the function or operator at the top element itself.) Upon finding a problematic child, the user can click it in the Tree View to have FormulaForge highlight the subexpression it represents in all views (the Text and Math Views in addition to the Tree View). Looking at this subexpression may reveal that its principal function or operator causes the error. If not, the user can proceed successively further down the Tree View, looking at each level for an element that has an incorrect or suspicious value and examining the subexpression that produces that value until one reaches an element for which the error is apparent. Debugging a formula in this fashion lets the user concentrate on only the subexpression(s) in error.
Once an error in a subexpression is identified, the user can correct it by draganddrop editing in the Tree View, as shown in the Debugging a Formula screencast on this website and which will also be described in a future blog post.
Below is a fairly simple spreadsheet that attempts to compute how inflation increases the monetary value of a loss. The spreadsheet has a problem, though. The values in range B3:B12, which represent the increasing losses, should all be negative. Instead, they are alternately negative and positive.
Below is FormulaForge’s Tree View for the formula in cell B4. You can see the value 10200 of the formula in red next to the top element. (FormulaForge does not attempt to copy the number format for the cell from Excel.) This value should be 10200. Examining the children of the top element shows that the value of the first argument of the IF function is false and that the value of the IF function is that of its third argument, which is 10200 and not 10200. The presence of a unary minus operator in this argument appears to be the problem with the formula.
Removing this unary minus operator yields the following Tree View, which shows the correct value next to the top element.
Finally, copying the formula in cell B4 to cells B5:B12 produces the following corrected spreadsheet, in which values in the range B3:B12 no longer alternate between negative and positive.
Although this example involves a fairly simple spreadsheet, the technique used to debug it can be used to debug very complicated formulas, including those in which the error is buried deeply. Using FormulaForge makes it easy to plumb those depths without getting lost in the shallows.
]]>Our primary goal in developing FormulaForge was to help Excel users understand and construct all kinds formulas. As Steve shows in his blog post, Getting a Good Look at a Formula, it is easier to understand mathematical formulas when they are typeset mathematically. Similarly, it is easier to understand algorithmic formulas when they are displayed in a tree that reveals their algorithmic structure. For this reason, FormulaForge shows three views of each formulas; a Text View, a Math View, and a Tree View.
Here is how Formula Forge displays the quadratic formula. Although wellknown by mathematicians, it is nonetheless complicated.
One can see the text view of the formula in the Text View pane in much the same form as in the Excel formula bar. Although the formula is primarily a computation, it is difficult to discern what that computation is simply by looking at the Text View. The Math View, however, shows the formula in much the same form as it would appear in a mathematics text book. In this view, it is clear what the overall computation is, and for users with a mathematics background, it is clearly the quadratic formula. Even for formulas that don’t correspond to wellknown formulas, the Math View can make the computation more clear than the simple Text View.
One way to understand complicated formulas is to examine their constituent subexpressions, which are easily selected using FormulaForge. Clicking anywhere in the Text View or in the Math View selects the smallest subexpression that contains the selection point. Clicking any element in the Tree View selects the smallest subexpression containing that element. The following image shows the result of selecting the subexpression corresponding to the SQRT function.
By selecting this subexpression, the user can focus attention on understanding the value of the SQRT function in this formula and how that value is computed from the subexpressions that compose the argument to the function. It does not matter how the user selects this subexpression: FormulaForge synchronizes the resulting views by highlighting the selected subexpression in each of the views. FormulaForge also guarantees that, no matter how the subexpression was selected, it is a complete subexpression. Excel itself neither makes any such guarantees nor makes it easy for users to select entire subexpressions. In Excel users can select the text “SQRT(B2“ even though that text doesn’t represent a complete subexpression, and Excel provides no assistance in expanding that selection into a complete subexpression. As a result, selection in FormulaForge is much more useful than selection in Excel for understanding how formulas work.
FormulaForge’s synchronized display of formulas in different views allows the user to approach understanding and debugging formulas at two different levels. At a high level, the Math or Tree View may reveal details that are easy to miss in the standard Excel Text View but much more apparent in the overall views they provide of a formula. Largescale structural problems or purely mathematical mistakes may become evident at this level. For example, deeply nested parentheses in the Text View may have hidden the fact that a factor belonging in the numerator of a fraction actually wound up in the denominator. At a lower level, the breakdown of a large formula into its constituent subexpressions, each with its value visible in the Tree View, can quickly point out how an error in one part of the formula has resulted in the wrong value for the entire formula. In these ways, multiple views, together with synchronized highlighting of subexpressions, provide a very powerful tool not just for understanding complex formulas but also for debugging them.
]]>Indeed, all formulas in Excel present nearly the same appearance, namely, that of a linear sequence of symbols. How then can one be distinguished from another?
These dilemmas, in Flatland and in Excel, create serious dangers. In Flatland, “triangular houses were universally forbidden by Law” because their hardtodiscern vertices “might do serious injury to an … absentminded traveller … running against them.” In Excel, bestpractices dictate against dangerous shapes for formulas. Such laws and practices makes life difficult, both in Flatland and in Excel.
Flatland residents must learn to distinguish shapes using senses other than sight. They “distinguish by the voice … the Equilateral, the Square, and the Pentagon.” However, for more complicated figures, “the process of discriminating and being discriminated by hearing increases in difficulty.” Thus they resort to their “sense of touch,” which, “stimulated by necessity, and developed by long training, enables [them] to distinguish angles.”
Excel users must similarly learn by long training to distinguish correct from incorrect formulas by indirect means—by checking them with sample data, by using the Evaluate Formula dialog box, by turning error checking on, by tracing precedents and descendents, … How much easier it would be if Flatland residents could just see shapes and Excel users could just see formulas!
The narrator of Flatland has an epiphany when he visits threedimensional Spaceland: “I looked, and, behold, a new world! There stood before me, visibly incorporate, all that I had before inferred, conjectured, dreamed.”
Excel users stuck in its onedimensional formula bar can have a similar epiphany by visiting another dimension—one with which they are already familiar. Who, after all, doesn’t find it easier to recognize the quadratic formula or the normal distribution function when presented in ordinary twodimensional mathematical notation rather than as onedimensional sequences of symbols?
(B3+SQRT(B3^24*A3*C3))/(2*A3) 
1/SQRT(2*PI())*EXP(A2^2/2) 

And who, when trying to understand why Excel produces an unexpectedly large value for the righthand formula when A2
is 3, wouldn’t like to see a picture
which shows that Excel evaluates A2^2
as (A2)^2
rather than as (A2^2)
, as mathematically trained users would expect?
Just as Flatlanders need to see where they are going, less they be pierced by hardtodiscern sharp angles, so formula writers need to see where they are going, lest their users be pierced by unseen errors in formulas. Although Flatlanders are stuck in two dimensions, Excel users need not be stuck in one. FormulaView and FormulaForge both exploit two dimensions to make it easy to recognize and understand formulas. Their math view typesets formulas, and their tree view shows a formula’s hierarchical structure. You can try the math view online or download a free copy of FormulaView by visiting http://formulaforge.com/formulaview. Try it, and escape the tyranny of one dimension!
]]>To keep the contents of his sheet as compact as possible, Rob wanted a single, large formula (which he eventually replicated in other rows) in a particular cell. To get there, however, the two of us ended up constructing formulas in other cells that contained subexpressions of the formula he really wanted. We eventually combined these into a single formula (after adjusting for relative references). The whole process took a long time.
That caused us to think about how the process of constructing and editing a complex formula in Microsoft Excel can be very timeconsuming. In particular, we felt that the following enhancements would allow formula construction and debugging to happen much more quickly and painlessly.
Along with another cofounder, Steve, we built an Excel addin, FormulaForge, to solve these problems. This web site contains considerable descriptive material as well as screencast videos to show you how FormulaForge works.
FormulaForge is in beta and can be downloaded for free. If you’re interested in doing so, please simply send your suggested username and password to info@formulaforge.com, and we’ll enable access to our download page.
Finally, although FormulaForge allows reading, displaying, editing, and writing complex capabilities, we have a free addin, FormulaView, that provides only the reading and displaying functions of FormulaForge. You can download that addin for free. We simply ask that you register a name and email address. We periodically send email to our registered users to inform them of upgrades.
]]>