How can I detect inconsistent formulas? - openoffice.org

Is there a way to automatically highlight inconsistent formulae, just like Excel does?
What I mean is if I have a range of cells with the same formula (structure) but one of those have a different formula, Excel will mark that cell as this is a potential error.
Is this function available in OOo Calc? I've looked at the Detective functions but none of those seem to do the job.

Excel dispenses the inconsistent formula error largely through comparing the R1C1 formula equivalents to adjacent cells since the R1C1 version does not change. If you have numbers in A1:C9 and you total the numbers for each column in A10:C10, the formulas as xlA1 are =SUM(A1:A9), =SUM(B1:B9) and =SUM(C1:C9) but as xlR1C1 they are all =SUM(R[-9]C:R[-1]C) (or =SUM(R1C:R9C) if absolute references are preferred). This makes it very easy for Excel to compare one formula against another to see if they are identical or not as viewed from the R1C1 perspective. So easy, in fact, that the operation can be performed as an on-the-fly background operation.
Unfortunately, OpenOffice Calc does not support R1C1 addressing outside of the INDIRECT and ADDRESS functions. This makes it much more difficult to compare the formulas in adjacent cells as each formula has to be have each internal cell/range address parsed as referenced by the cell where the formula resides. While this is possible through programming, it is not a native OpenOffice Calc capability. There may be some work done in this area (Google should know) but it would almost assuredly be an on-demand macro and not a background operation.

Related

How can I combine these 2 functions without going over the 50,000 character limit?

I tried to simply replace anytime I referenced the cell into the actual function inside of the referred cell. This normally works in every single other function
I've done this with, but in this case, it's a big function and it gets referred to many times. This causes it to go over the 50,000 character limit for functions and this method no longer applies.
check out this spreadsheet to see the functions I'm talking about:
https://docs.google.com/spreadsheets/d/1RFA8s68TSQI2jQSOQm2_Ma776vC1LUQn7JP9tg-gZ1g/edit?usp=sharing
here's the formula:
=index(fixed(regexextract(A3,"[\d.]+")*product(10^vlookup(regexextract(A3,regexreplace(A3,"([A-Za-z])","($1)")),split(flatten(regexextract(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),regexreplace(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),"(.)","($1)"))&"❄️"&sequence(13,1,3,3)),"❄️"),2,0))/(2.5*B3+1)/10^sumproduct((exact(index(split(flatten(regexextract(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),regexreplace(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),"(.)","($1)"))&"❄️"&sequence(13,1,3,3)),"❄️"),,1),C3))*(index(split(flatten(regexextract(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),regexreplace(flatten(split("Kk,Mm,Bb,Tt,q,Q,s,S,Oo,Nn,d,Uu,D",",")),"(.)","($1)"))&"❄️"&sequence(13,1,3,3)),"❄️"),,2))),D3)&C3)
I couldn't find an efficient way to automatically convert back to the best unit because we are dealing with huge numbers that get turned to scientific notation preventing us from easily getting the actual length of the number. For this reason, I added a cell (C3) where you can specify the unit you want. I also added another cell (D3) where you can specify the amount of decimal places you want to display.

Why is this Google Sheets Concatenate Formula giving me weird results?

I'm trying to use Google Sheets to concatenate a bit of data. It works 90% of the time, however on certain numbers, I get an odd result. I have to copy the result of this data and paste it into a financial program in a specific format and am using the concatenate formula to do this. The format the program requires is that each field be separated by one period, even if it is a dollar amount as the program will automatically move the decimal point two places to the left while it is evaluating the information. The issue is that on some numbers the formula adds two periods between the fields, which stops the evaluation of the data in our financial program.
Here is a screenshot including the formula
You can see that it works with most numbers in the amount column, but with two of the amounts and several others, it adds two periods after the amount.
Would you please take a look at this and see if you can help me find the issue?
Thank you!!!!
Looks like it's an existing floating point calculation error in Google Sheets, the multiplication by 100 did not return exact value for certain numbers but with extra very small decimal. That's why there's an additional period on the result.
As a workaround, use ROUND() upon multiplying by 100 to "snap" it to an integer.
Sample:
References:
Floating Point Calculation Error
use just:
=B2&"."&ROUND(C2*100)&"."&D2

Google sheets - Subtraction giving unexpected results

I have the following sheet:
Why does the difference of two cells with the same value (J7 & J8) not equal zero?
Here is an example spreadsheet.
Switching to Format/Number/Scientific on that cell, you can see the leftover value:
These rounding errors are clearly a regular thing. You can use a formula such as =E3-round(E3,2) to see them for any cell:
Clearly, allowing for a small value in the conditional formatting would avoid the problem:
To add to #df778899's answer, this is not just a "regular thing". It is an unavoidable consequence of floating-point arithmetics.
The surprising thing is that Google apparently represents numbers internally in the floating-point format. For the same numbers, Excel gives the correct result in the equality comparison, which suggests that unlike Google, Excel's representation is fixed-point.
EDIT: upon double-checking, one can find examples of floating point errors in Excel too, so this paragraph is not correct.
Students in computer science are taught to always use approximated and not exact comparison for FP numbers. I think it's unreasonable to expect this from spreadsheets users, though.
In practical terms, when comparing fractionals to other fractionals, avoid using
=if(j7=j8, ...)
or EQ(). Instead, use
=if(abs(J7-J8)<0.0001, ...)
(with appropriate arbitrary precision)

How can I use the OFFSET() formula with a range of values?

EDIT: Disclaimer about the XY problem: The actual, concrete problem I'm trying to solve is: How can I make "recursive" (is that the right term here?) formulas that use infinite ranges in Google Spreadsheets/Excel? The solution I'm working with involves the OFFSET() formula. I'm asking this question because I'd like to get an extensible understanding of the way formulas use and implement ranges, especially infinite ranges.
I'm working in Google Spreadsheets and trying to create ArrayFormulas that will automatically expand without needing to use the fill handle as new data is added in the requisite columns.
To do this, I want to use infinite ranges such as A2:A when I do calculations so that no matter how much data is added, I'll never have to drag-fill any data or formulas and I can just let the spreadsheet iterate and do the work.
I'm running into a problem, though, when I try to use these infinite ranges with the OFFSET() formula. What I'm trying to do is have each cell in the range pull values from a couple of the cells next to it (thus the offset), do a simple calculation with those values, and make that the new cell value. But because the formula interprets the instruction as attempting to offset an entire (infinite) range of values, it returns a #REF! error. Here's a shared example sheet that demonstrates what I'm trying to do.
https://docs.google.com/spreadsheets/d/1V3ldSBoCrzyVWcn66wFBkDOmxt6iuYgtiU_H4KQ6J14/
If for some reason you can't see the formulas, the formulas I'm using are:
C3 =ArrayFormula(Offset(C3:C, 0, -1) - Offset(C3:C, -1, -1))
F4 =Arrayformula(Offset(F3:F, 0, -1) + Offset(F3:F, -1, 0))
Both of these return a #REF! error. C3's alt-text reads: "Error: Result was not automatically expanded, please insert more rows (1)." F3's alt-text reads: "Error: Circular dependency detected."
I'm decently confident why these don't work - you're apparently not allowed to use and refer to ranges this way. I don't, however, know how to fix this.
The two use-cases in the spreadsheet are essentially the same thing, backwards. Chances are if I can figure out one I can reverse-engineer it to work for the other one, but I've had no luck so far.
I've Googled around a lot and while I've never found anything that solves this problem, a lot of similar problems seem to be solved by using the INDIRECT() function. I can't understand how this would apply here, though, that function seems to be strictly for parsing values dynamically from cells with variable input.
(I should probably mention that this data is on a back end sheet and it's getting pulled on another sheet to display some charts on the front end. I wouldn't ask a question here if this data was the only thing involved.)
Any help or a step in the right direction would be appreciated.
If I'm understanding your question, one way to make an offset function expand automatically is to attach a count function, eg. in excel
=offset(C2,,,counta(C:C))
However, this will give you a circular reference error. To address this issue, this is one solution that I have used:
"OFFSET(C3,,,MATCH(9.99999999999999E+307,OFFSET(C3,,,ROWS(C:C)-ROW(C3))))"
This function passes an array based on the last number cell in the column. And for it to be used properly, it needs to be wrapped in a function that can handle arrays, like SUM().

List Comprehension in an Open Office Spreadsheet

List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct.
I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count all of the values in a range of cells that fall between a high and low bounds. I instantly thought that list comprehension would do the trick, but I can't find anything analogous in Open Office. There is a function called "COUNTIF", and it something similar, but not quite what I need.
Is there a construct in Open Office that could be used for list comprehension?
CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. Alternatively you can use additional column with If to display 1 or 0 if the value fits in range or not accordingly:
=If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0)
Then only thing left is to sum up this additional column.
Assuming:
your range is A1:A10
your lower bound is at B1
your upper bound is at B2
then what you want can be achieved by:
=COUNTIFS(A1:A10, ">" & B1, A1:A10, "<" & B2)
(you might need to change commas into semicolons, depending on your language preference for decimal point)
Quoting from the installed OpenOffice documentation:
The logical relation between criteria can be defined as logical AND (conjunction). In other words, if and only if all given criteria are met, a value from the corresponding cell of the given Func_Range is taken into calculation.
This function is part of the Open Document Format for Office Applications (OpenDocument) standard Version 1.2. (ISO/IEC 26300:2-2015)

Resources