[Solved] Notation of formulas to add comments

Discuss the spreadsheet application
Post Reply
robbyn
Posts: 62
Joined: Sat Jun 26, 2021 10:01 pm

[Solved] Notation of formulas to add comments

Post by robbyn »

Is there a way to put remarks into formulas so that I can better understand them months later?
Last edited by MrProgrammer on Mon Aug 30, 2021 3:43 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved]
Libreoffice v7.2.0.4 on Ubuntu 20.04 Locale en-GB
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Notation of formulas

Post by RoryOF »

Attach a Comment/Annotation -- /Insert /Comment
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
MrProgrammer
Moderator
Posts: 5424
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Notation of formulas

Post by MrProgrammer »

robbyn wrote:Is there a way to put remarks into formulas so that I can better understand them months later?
• Keep formulas easy to understand by breaking them into small pieces stored in multiple cells. This process also helps investigate difficulties with the result not being as expected. Long, complex formulas with many nested functions are troublesome. Experienced Calc users avoid them. Simple formulas are less likely to need comments.

You can use Insert → Names → Define to create meaningful names for expressions so you can use:
=July_rent + Gas + Coffee
=MID( Our_four_sales_districts ;D5;3)
Read about defined names in Help → Index or in User Guides (PDF) or searching for topics about that in the Calc Forum.

• You can use an IF function to add a comment and a date to any expression or sub-expression:
=IF("yyyy-mm-dd";expression;"This is a comment")
The value returned from the function is expression; the comment is ignored. Put the date in double quotes and use only the yyyy-mm-dd format. If you always use a 4-digit year, you can omit the quotes since 20yy-mm-dd is a nonzero numeric expression for any year, month and day. If you don't want to provide a date, use TRUE() or the value 1:
=IF(TRUE();314.16;"July rent") + IF("2021-08-23";27.18;"Gas") + IF(2021-08-23;4.44;"Coffee")
=MID(   IF(1;"AtlBosChiDet";"Our four sales districts")   ;D5;3)
RoryOF wrote:Attach a Comment/Annotation -- /Insert /Comment
I have not had a good experience with this feature and never use it.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
robbyn
Posts: 62
Joined: Sat Jun 26, 2021 10:01 pm

Re: Notation of formulas

Post by robbyn »

I was hoping that I could put something like #explanation# into a formulae at each section within it:

IF(CAT=TIGER#only red tigers#,"Boo"#be careful#,"Bang"#too late#)
Libreoffice v7.2.0.4 on Ubuntu 20.04 Locale en-GB
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Notation of formulas

Post by RoryOF »

Or add a column of text to contain the explanations for the nearby formula. You can Hide it if it is too obtrusive in daily use.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
Lupp
Volunteer
Posts: 3755
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Notation of formulas

Post by Lupp »

It won't help anybody, and is only a reminescence:
ALGOL had what the questioner hoped for: Separating two parameters ("formal" in declarations or "actual" in calls), the syntax allowed as delimiters (BNF production)

Code: Select all

<parameter delimiter>::=,|)<letter string>:(
Good old days? Just consulted my manual from 1965.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: Notation of formulas

Post by eeigor »

We can use N() to add a comment like this:
=SUM(A1:A100) + N("Sums the first 100 rows of column A")
which is effectively the same as:
=SUM(A1:A100) + 0
which is just:
=SUM(A1:A100)

We just have to be careful to place the N() function outside of a math operation.
Last edited by eeigor on Tue Aug 24, 2021 7:42 pm, edited 1 time in total.
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
robbyn
Posts: 62
Joined: Sat Jun 26, 2021 10:01 pm

Re: Notation of formulas

Post by robbyn »

For important and dependent functions I use a different method. I reserve an area for these difficult to check functions and set it up as follows:

Is the cat bigl? If T. 100 if F. 10
Is it as big as a tiger? If T. 100 if F. 10
Does it have big teeth? If T. 100 if F. 10
total 300

elsewhere:
If total =300 T "run" F "Hide"

I recall some test programs results used a similar system, so that if the total was say 16 there could only one set of answers that that would produce 16, and so a specific response could be made. Do you recall the pattern of those numbers? They may have been 2, 4, 16, 32 etc but I am unsure if that is the right pattern.
Libreoffice v7.2.0.4 on Ubuntu 20.04 Locale en-GB
robbyn
Posts: 62
Joined: Sat Jun 26, 2021 10:01 pm

Re: Notation of formulas

Post by robbyn »

eeigor wrote:We can use N() to add a comment like this:
=SUM(A1:A100) + N("Sums the first 100 rows of column A")
which is effectively the same as:
=SUM(A1:A100) + 0
which is just:
=SUM(A1:A100)
Thank you that was what I was looking for when I started the thread.
Libreoffice v7.2.0.4 on Ubuntu 20.04 Locale en-GB
Post Reply