When trying to get an output of "#.## M" I receive an error, but when I remove the M, I do not. Having the M at the end is imperative to the end result. Formatting alone outside of the formula does not work.
I've tried several web searches that did not fix the issue. I don't know what else to attempt.
=(TEXT('National Economy & Finance'!C13, "#.## M"))
I expect an output of 42.42 M but instead receive the following error:
Invalid format pattern '#.## M' in TEXT evaluation.
You just need to escape the M:
=(TEXT('National Economy & Finance'!C13, "#.## \M"))
"#.##" would be interpreted as a decimal number and "M" would normally be interpreted as month, so you can't have both together in the same format.
You can also just put
=(TEXT('National Economy & Finance'!C13, "#.##"))&" M"
Related
I'm making a list for buying groceries in Google Sheets and have the following value in cell B4.
0.95 - Lemon Juice
2.49 - Pringle Chips
1.29 - Baby Carrots
9.50 - Chicken Kebab
What I'm trying to do is split using the dash character and combine the costs (0.95+2.49+1.29+9.50).
I've tried to use Index(SPLIT(B22,"-"), 7) and SPLIT(B22,"-") but I don't know how to use only numbers from the split string.
Does someone know how to do this? Here's a sample sheet.
Answer
The following formula should produce the result you desire:
=SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT(SPLIT(B4,CHAR(10)),"(.*)-"))))
Explanation
The first thing to do is to split the entry in B4 into its component parts. This is done by using the =SPLIT function, which takes the text in B4 and returns a separate result every time it encounters a specific delimiter. In this case, that is =CHAR(10), the newline character.
Next, all non-number information needs to be removed. This is relatively easy in your sample data because the numbers always appear to the left of a dash. =REGEXEXTRACT uses a regular expression to only return the text to the left of the dash.
Before the numbers can be added together, however, they must be converted to be in a number format. The =VALUE function is used to convert each result from a text string containing a number to an actual number.
All of this is wrapped in an =ARRAYFORMULA so that =VALUE and =REGEXEXTRACT parse each returned value from =SPLIT, rather than just the first.
Finally, all results are added together using =SUM.
Functions used:
=CHAR
=SPLIT
=REGEXEXTRACT
=VALUE
=ARRAYFORMULA
=SUM
Firstly you can add , symbols start and ends of numbers with below code:
REGEXREPLACE(B4,"([0-9\.]+)",",$1,")
Then split it based of , sign.
SPLIT(A8, ",")
Try below formula (see your sheet)-
=SUM(ArrayFormula(--REGEXEXTRACT(SPLIT(B4,CHAR(10)),"-*\d*\.?\d+")))
I have the following requirement.
I need to validate with Rails that a phone number begins with +1 and is met with exactly 10 digits after this? So far, I have this regex expression.
^+1\d{10}
This is not working and I'm having a bit of trouble trying to tweak this to match exactly what I need. Does anyone have any ideas the validation has to catch this exactly.
+19564321234
etc. Help would be appreciated. Thank you.
You have two problems with your regular expression:
You have not escaped the plus sign, so it reads, "match the beginning of a line, followed by one or more (+) zero-width characters, followed by 10 digits"
You have omitted an end-of-string anchor, so \d{10} will match a string of 10 or more digits
You need to write:
r = /\A\+\d{10}\z/
"+1234567890".match? r #=> true
"1234567890".match? r #=> false
"+1234567890123".match? r #=> false
I've used the beginning-of-string anchor, \A, rather than the beginning-of-line anchor ^. The latter would be in problem only in some extreme cases, such as:
"dog\n+1234567890".match? /^\+\d{10}\z/ #=> true
Start your engine!. To see it tested against several strings one must change the anchors to ^ and $ and add the multiline (/m) modifier.
I would like to compute in spss a multiple if condition. My data looks like this:
DO IF (A<75 & DN<75).
COMPUTE AD=0.
else if (A=75 & DN<75).
COMPUTE AD=(A-75).
else if (A<75 & DN=75).
COMPUTE AD=(DN-75).
else if (A=75 & DN=75).
COMPUTE AD=[(A-75)+(DN-75)].
END IF.
EXECUTE.
It gives me an error at the last compute command, saying:
The expression is incomplete. Check for missing operands, invalid operators,
unmatched parentheses or excessive string length.
Execution of this command stops.
Can anyone tell me please how should I formulate the equation in order to be acceptable to spss?
Right, square and curly brackets are not allowed in COMPUTE expressions, only parentheses. Spaces in between nested parentheses are allowed, but not required.
I need to be able to print Hebrew characters on my Epson TM-T20ii. I am trying to get my printer to switch to character code page 36(PC862) using
ESC t36
for some reason the printer is switching to code page 3 and then printing the number 6.
Is there a way to let the printer know that the 6 is part of my command?
If you know of a different workaround please comment below.
Thanks
You are making a mistake, you aren't meant to replace n with an actual number.
The proper syntax in your case would be ←t$
Explanation: the manual says "ESC t n", n referring to the page sheet, however you don't replace n with a number rather with the ASCII character n, so in your example 36 = $ because $ is the 36th character on the ASCII table.
I'm trying to automate some output using printf but I'm struggling to find a way to pass to it the list of arguments expr_1, ..., expr_n in
printf (dest, string, expr_1, ..., expr_n)
I thought of using something like Javascript's spread operator but I'm not even sure I should need it.
For instace, say I have a list of strings to be output
a:["foo","bar","foobar"];
a string of appropriate format descriptors, say
s: "~a ~a ~a ~%";
and an output stream, say os. How can I invoke printf using these things in such a way that the result will be the same as writing
printf(os,s,a[1],a[2],a[3]);
Then I could generalize it to output lists of variable size.
Any suggestions?
Thanks.
EDIT:
I just learned about apply and, using the conditions I posed in my OP, the following seems to work wonderfully:
apply(printf,append([os,s],a));
Maxima printf implements most or maybe all of the formatting operators from Common Lisp FORMAT, which are quite extensive; see: http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm See also ? printf in Maxima to get an abbreviated list of formatting operators.
In particular for a list you can do something like:
printf (os, "my list: ~{~a~^, ~}~%", a);
to get the elements of a separated by ,. Here "~{...~}" tells printf to expect a list, and ~a is how to format each element, ~^ means omit the inter-element stuff after the last element, and , means put that between elements. Of course , could be anything.
There are many variations on that; if that's not what you're looking for, maybe I can help you find it.