Blog Post

Excel Blog
2 MIN READ

A new way to debug formulas from Excel Labs

jack-williams's avatar
jack-williams
Icon for Microsoft rankMicrosoft
Dec 11, 2023

Have you ever found yourself tangled in a web of complex Excel formulas, desperately trying to pinpoint the source of an error? Fret no more! The latest experiment from Excel Labs is a new formula debugger, available within the Advanced Formula Environment (AFE).

 

The AFE debugger

Getting started

The debugging capabilities are activated using the new button on the Grid page in AFE. When the button is activated the debugger will be visible in the same editing pane, and you are ready to go!

 

Key features

Here are some of the key features to look out for:

 

- Live debugging

The debugger updates as you type, making it quick to explore how different variations of a formula are evaluated.

Live debugging as you edit the formula

- Evaluation steps

Each evaluation step is shown, with highlights and underlines making it easy to see what changed at every step.

Evaluation steps show each change in the formula

- Range preview

View a preview of the grid when hovering over a reference. Previews show the surrounding context to make it easier to navigate.

Preview referenced grid ranges

- LAMBDA debugging

Debug LAMBDA formulas, such as SalesForBestCategory, shown below. Every function call is contained in an expandable card. This lets you dive into the particular functions you are interested in, to see how they evaluate.

Debug LAMBDA formulas

Function support

Not all functions are supported just yet. If a function or scenario is blocking your work, we would love to hear about it!

 

In case you missed it: Sheet-defined functions

Another experimental feature in the advanced formula environment is the ability to automatically convert a multi-cell calculation into a function, also known as sheet-defined functions. This capability has been part of AFE for a while, but in case you missed it – here is a brief overview.

 

Often, we find ourselves spreading a complex calculation over many cells, like this one, that extracts an ID from a piece of text.

 

Multi-cell calculation for extracting an ID

 

After writing the calculation we are either faced with many intermediate cells, or we must roll the formulas into a single mega-formula. With AFE and the “Add function from grid” feature, we can automatically convert these formulas into a tidy function using three simple steps:

 

  1. First, select the range containing the formulas that will make up the function.
  2. Then click the “Add function from grid” button and provide the references that will define the inputs and outputs. Sometimes, AFE can automatically detect the inputs and outputs based on the dependencies.
  3. Finally, AFE will present you with the generated function that combines the formulas in the range. If you use labels adjacent to formulas, AFE can also use those to generate friendly parameter names, like Text or After.

Define a custom function from cells in the grid

 

How to access

The debugger will be pushed to Excel Labs automatically and there is no need to explicitly update the add-in. If you do not have Excel Labs, you can install the add-in from the Office store. Follow this link.

Updated Dec 08, 2023
Version 1.0

18 Comments

  • lori_m's avatar
    lori_m
    Iron Contributor

    This will be very useful, and initial results for functions that are supported look promising...

    AFE results that don't match are highlighted in red below - however if entered with CSE they do match.

     

    I would actually tend to question the DA results here as the AFE ones make more sense to me

     

  • jflynnz's avatar
    jflynnz
    Copper Contributor

    Interesting, really great work/tool here!

    Trying to dig into using it more, and noticing that many of my "formula steps" pane shows an error:

     

    Maximum number of cells in debugger exceeded.

    I'm guessing this is due to using dynamic named ranges/spill ranges?

    For instance:

     

     

    =SORTBY(
        FILTER(
            'Line Info Entry'!A15#,
            Data_StructureOrder <> ""
        ),
        Data_StructureOrder
    )

     

     

    recreates this for me.
  • Sameer_Bhide's avatar
    Sameer_Bhide
    Iron Contributor

    jack-williams 

    This is a great start.

     

    I just wrote a formula = FILTER(D, D[Product]="ABC","-") - It errors out saying too many cells, then I reduce the table size and then it errors out saying the FILTER function is not supported

    Are these limits (number of cells, list of unsupported functions) defined somewhere?

     

    Cheers

    Sam

     

     

  • mtarler's avatar
    mtarler
    Silver Contributor

    In theory this is HUGE and will help a ton.  The interface seems to have a lot of features (colors, formatting, etc...) to help the user understand but at least for me, I will need some time to get used to it.  It appears any reference to a spilled range isn't supported yet (i.e. A1#)

    NOTE: I think I found a slight bug.  I'm guessing it is due using an HTML type interface but TEXT with multiple spaces is not showing the multiple spaces.  Specifically  REPT(" ", 10)  resulted in  text: “ ” . that said the formula still recognizes that there are 10 spaces and MID(REPT(" ", 10) & "ABCDEFGHIJKL" , 9, 1) still returns " ".  It is just a display issue.    

     

     
  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    AlexC84 , lambdas and even direct recursion work. XLOOKUP is not supported, at least in some variants.

  • AlexC84's avatar
    AlexC84
    Brass Contributor

    SergeiBaklan I also saw that error when looking at a lambda function; it used arrays which might be the reason. It was working ok with basic formulas

     

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    Great addition! First I see when started with debugger is

    The formula uses features which the debugger does not yet implement.

    but need to play more.