How to use the new LET() function introduced in 24.8?

I’m having trouble following the doc to understand the new LET() function introduced in v24.8. It’s behaving in ways that I don’t understand and the formulas are producing results that I think they shouldn’t be able to. Let me explain.

In my Calc file, the first sheet is named “InputLines”. Column A has a few hundred lines of dictated text. Column A is named “InputLine” so that I can refer to it in formulas with that name.

The second sheet is named “Parse” and it has formulas using REGEX() to extract info from the InputLines. Column B has date entries and that column is named “LineDate”. The other parsed-out data columns have names beginning with “Line...” so they are together in the list of names in the Manage Names window.

All of the formulas in the Parse sheet are wrapped with the same IF function:

=IF( InputLine = "" , "-"
    . . .
)

This does nothing other than to flag which of the input lines are empty and show tha the formula is there. This makes it easy at the bottom of the sheet to see how far down I have copied the formulas so that I know how far to copy when I have made a change or when the number of input lines exceeds how far the formulas have been copied.

I tried to get an extremely simple instance of LET to work. First, to make sure that my names etc. were all working as expected, I created this simple formula:

=IF( InputLine = "" , "-" ,
    
    LineDate
    
)

This works as expected. It displays the date that is parsed out from the InputLine by the REGEX formula in the LineDate column. And as expected, the IF first argument is TRUE so the second argument is skipped and the third argument is calculated.

So then I tried putting that LineDate inside a LET:

=IF( InputLine = "" , "-" ,
    LET(
        ThisDate , LineDate ,
        ThisDate
    )
)

In my interpetation of the LET manual page, the local-to-LET variable ThisDate should be given the calculated value of LineDate, which in my previous calculation was the date value extracted from the corresponding input line. Then that variable should be presented as the calculation result.

But it isn’t. What I get instead of the value of LineDate is simply “-” — it’s as if somehow the LET function is influencing the calculation of the IF, which makes no sense to me at all.

How can I get LET to do what I expect in this situation? What am I not understanding in the manual page? What is the manual page not explaining that it should? Is the name LineDate interpreted differently inside the LET than it had been without the LET? Even if that’s the case, why did I get “-” instead of an error. Or is it a bug in this new feature? But how could even a bug in LET influence the IF calculation?

I’m baffled. Any suggestions?

There’s tdf#164997 and tdf#164998. The former is fixed in 25.8 - though obviously not completely, because it still fails for me. So - note that in currently released versions, it may give grave surprises.

Thanks Mike. So it’s a BUG. Foo. I guess I’ll have to reorganize my calculations using intermediate values in extra columns. Of done that before, and elsewhere in this project. I was just hoping that LET would be a clean and elegant solution and I’ve been looking forward to trying it. I still don’t have a clue how the IF choice is affected, although I suppose it could be related to tdf#164997, since that is a case of errors being propagated when they shouldn’t. (And you mean “25.2” not “25.8”, right?) I’ll give 25.2 a try and I have a workaround if still doesn’t work. Thanks.

No I mean 25.8 not 25.2. Yes I talk about the version to be released in half a year - it’s about development. It’s also what’s explicitly mentioned in the bug’s whiteboard as the target :slight_smile:

I see that now. OK. I will use more “traditional” methods and not hold my breath. Thanks.

(OT?)
I’m considering a kind of alternative to LET(), currently based on user code (some UDFs mainly).
A realistic example file of the type you try to use LET() in would possibly help me.

AFAIK the only issue with »LET« is: you cannot use it »inside« other functions, but it works in case:

=LET( do all the stuff here )  
# or "connect" via operators like:
=foo + LET(  part stuff here ) * ham