Ignore any number in the tenth position in Open Offic Calc - openoffice-calc

I am trying to right a script for a current project but I need it to note display the number in the tenth position.
For example,
A1 = 9
A2 = 3
=SUM(A1+A2)
Would be
12
How ever how can I get it to display only 2?
The numbers will change with each entry. Sometimes it could be 9+45= 54 however I would want it to display only 4. Not sure how I would go about making it take away the number only in the tenth position.

You probably want something like:
=MOD(A1+A2,10)
Though I believe OpenCalc will use the semicolon as a parameter delimiter.

You can trasnform number to string then take last number. Something like this:
C1 = SUM(A1 + A2)
RIGHT(TEXT(C1,0),1)
The result is
2

You are looking for the Units position, not the Tens. The Units is always the furthest right character so just extract it right from there. No need to convert to string first
=RIGHT(SUM(A1:A2),1)

Related

What's the difference between LEN and <>"" when searching for values?

I initially learned that if I want to see if a cell has any contents to use if(A1<>"",.... But as I receive more and more assistance on SO, it seems most people use if(LEN(A1),... Is there a difference? Did I learn the wrong information? Should I ever opt for one over the other or just always use LEN from now on?
pretty much the same result. difference is:
LEN(A1) - checks if A1 has a length
A1<>"" - checks if A1 is not equal to "empty"
then there is a length of the formula itself (some prefer to save 1 extra character space):
A1<>"" has 6 characters compared to LEN(A1) 7 characters
the superiority of LEN comes when you need to check for character count like:
=IF(LEN(A1)=4, TRUE, FALSE)
eg. output TRUE only if A1 value has exactly 4 characters

Best way to show blank cell if value if zero

=COUNTIFS(Orders!$T:$T,$B4)
is a code that gives 0 or a +ve result
I use this across 1500 cells which makes the sheet gets filled with 0s
I'd like to remove the Zeros by using the following formula
if(COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*")=0,
"",
COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*"))
This calculates every formula twice and increases the calculation time.
How can we do this in 1 formula where if the value is 0 - keep empty - otherwise display the answer
I suggest this cell-function:
=IFERROR(1/(1/COUNTIFS(Orders!$T:$T,$B4)))
EDIT:
I'm not sure what to add as explanation. Basically to replace the result of a complex calculation with blank cells if it results in 0, you can wrap the complex function in
IFERROR(1/(1/ ComplexFunction() ))
It works by twice taking the inverse (1/X) of the result, thus returning the original result in all cases except 0 where a DIV0 error is generated. This error is then caught by IFERROR to result in a blank cell.
The advantage of this method is that it doesn't need to calculate the complex function twice, so can give a significant speed/readability increase, and doesn't fool the output like a custom number format which can be important if this cell is used in further functions.
You only need to set the number format for your range of cells.
Go to the menu Format-->Number-->More Formats-->Custom Number Format...
In the entry area at the top, enter the following: #;-#;""
The "format" of the format string is
(positive value format) ; (negative value format) ; (zero value format)
You can apply colors or commas or anything else. See this link for details
instead of your =COUNTIFS(Orders!$T:$T,$B4) use:
=REGEXREPLACE(""&COUNTIFS(Orders!$T:$T,$B4), "^0$", )
also, to speed up things you should avoid "per row formulae" and use ArrayFormulas

How do I make a cell return a value based on the characters

I have a cell that I want to use and IF statement to tell return information based on characters in the cell. I.E the cell has =M=WRFY, I want the statement to give me a start time based on the day within. I used this formula for the first set and it worked but for the next day it fails.
=IF(LEFT(I44,1)="S",H44,"")
I've tried entering the 2 where the 1 is to make it look at character 2 but its not working. Help!!

Select a node where an attribute contains a text that is of certain length after a certain character

I'm using Selenium IDE and can't figure out how to select a given element that has a certain attribute which contains some text (number) of a certain length after a specified character.
In order to better understand what exactly I would like to achieve please see below an example.
I have the following HTML element:
<div><h2 class="attribute" onclick="PropertyPopup.Show(63854, 4065)">test test</h2></div>
In my case both the numbers in the bracket (63854 and 4065) are changing dynamically and I'm mostly interested in the second number (4065). This can have a length of 4 or 7 so I would need an XPATH (combined with regexp?) that would extract only those elements where this number has a length of 4 for example (like in the above example).
So far I've used the following XPATH:
//div[h2[#onclick][string-length(#onclick)<=31]]
This is working fine at the moment (since in most cases when the second number has a length of 4, the whole line will have less (or equal) than 31 characters) but if the first number will contain 6 numbers (and the whole line will have 32 characters), the above example will not be selected. If I would put "<=32", then in some cases, it would select those elements where the second number has a length of 7 (like when the first number has a length of 3 and the second 7).
I've tried to use something like the below:
//div[h2[#onclick][contains(#onclick,', \d{4}']]
but this will not be recognized as a regexp and will look for an 'onclick' attribute that contain the word ", \d{4}".
Is there anything I could do in order to select the node only based on the second number (its length)?
thank you,
Szabi
You could try something like this:
//div[string-length(normalize-space(substring-before(substring-after(h2/#onclick,','),')')))=4]

Regex on multi-part field

I have one input field that will represent a height in feet and inches. Users want an inout mask on the field as well, so when typed, it will separate the two halves of my 4 byte field with a slash; i.e. XX/XX.
The first XX is feet, and can basically be any number, although this height represents loading docks, so I suppose anything over 15 or 20 feet would be ridiculous.
The second XX are inches, and needs to be limited between 0 and 11. I thought I came up with what I needed with jquery masked input plug in, but i couldn't get it to allow a single digit in one of the XX columns, and I don't want to force the user to enter a leading 0.
I'm thinking this is probably pretty easy to knock out with reg ex...I'm sure someone here can prove me right!
I wrote a blog post about using regular expressions for validating number ranges. It's generally not recommended, but in this limited case perhaps it's okay.
If you assume that the first XX can be 0-30 (to be safe), you can use this:
(30|[0-2]\d)\|(0\d|11)
Debuggex Demo