I'm having a problem with the following code.I would like to display the amount of money of people with the $ sign. In the interface there is a monitor that shows the actual money of an agent, but with the function word it shows to me all the decimal places possible (I inserted 2, but seems it doesn't care). The code is inside the monitor's reporter.
Thanks in advance.
word "$" sum [money] of people
When you use the function word, you are no longer displaying a number but rather a string. Because of that, the notion of decimal places no longer applies because you are looking at text.
That means you need to change the number of decimals the number has before you turn it into a string. Precision is a primitive that allows you to manipulate the number of decimals. Combining that with your code gives the following:
word "$ " precision sum [money] of people 2
Displayed below with brackets to make it a bit more clear what happens when.
(word "$ " (precision (sum [money] of people) 2) )
Related
I'm trying to make a flex expression which identifies money, to 2 decimal places. This isn't for any practical use, I'm just messing around with flex and trying to learn it.
I am looking for money in this format: $100.00 or $100000.00 or -$100.00
This is not much of an issue, I can use this expression:
[$][0-9]+[.][0-9]+
I can also add to it to detect negative numbers:
-?[$][0-9]+[.][0-9]+
My problem is, with how I have it $100.00 would be identified as expected, but $100.000000 would also be identified as a money token. How do I ensure that there are only 2 decimals shown?
Is there any way to tell Flex to limit the amount of characters in an expression? I could do something like this;
-?[$][0-9]+[.][0-9][0-9]
but this seems like a bad solution. What if I wanted 10 decimal places? Tagging lots of [0-9]'s on the end seems like a bad idea.
I have a field with the following types of string
X000233756_9981900025_201901_EUR_/
I firstly need to take take the characters to the left of the first _
Secondly I need to take the characters between the first and 2nd _
First _ is CHARINDEX('_',[Line_Item_Text],1) AS Position_1
Second _ is CHARINDEX('_',[Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1) AS Position_2
I was then expecting to be able to do
left([Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)-1) AS Data_1
Substring([Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1),CHARINDEX('_',[Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1) - CHARINDEX('_',[Line_Item_Text],1)+1)) AS Data_2"
Which should give me
X000233756
9981900025
But getting errors with incorrect number of functions when I start adding and subtracting from CHARINDEX Function.
Any ideas where I am going wrong?
TIA
Geoff
Actually, using the base string functions here is going to be an ugly nightmare. You might find that STRING_SPLIT along with some clever logic might be easier:
SELECT value
FROM STRING_SPLIT('X000233756_9981900025_201901_EUR_', '_')
WHERE LEN(value) > 6 AND NOT value LIKE '[A-Z]%';
This answer assumes that the third and fourth components would always be a 6 digit date and 3 letter currency code, and that the first (but not second) component would always start with some letter.
Demo
I like the idea of Word spelling out a number for me in certain scenarios as follows:
{ REF BookmarkName \* CardText }
However, when I try to spell out the total price of a quotation it fails to do so if the value is too high. Does anyone know where the limit is? Is there any way to overcome it?
Thanks ;-)
This feature dates back to around 1990, when the amounts people worked with were much more modest than now. There is, indeed, a built-in limitation of six digits before the decimal point: 999'999 is the largest integer the field switch \* cardtext supports.
It is possible to have higher numbers, but it requires combining field codes to work around the limitation. Many, many years ago, a group of us in the Word forum on Compuserve figured out a way to do this and I posted it on my website (http://homepage.swissonline.ch/cindymeister/NbrFAQ.htm#Millions). I copy it verbatim, below:
There are special formatting switches that allow you to display a
number as text, either with or without "dollars". (For more
information on the number formatting switches, look under Switches;
field switches; number formats in Word's Help Index.) But the program
is limited to displaying the information for numbers less than one
million. In order to display amounts in the millions as text, you need
to use a combination of nested fields. Example:
{ QUOTE { = SET n 1999999 }
{ IF n < 1000000 "{ = n \*cardtext }" "{ = int(n/1000000) \* cardtext } million
{ SET r { = MOD(n, 1000000) } }
{ IF r = 0 "" "{ = r \* cardtext }" }"
} \* caps \* CharFormat
}
Displays one million nine hundred ninety-nine thousand nine hundred
ninety-nine.
The QUOTE field keeps everything together. The number you
want to work with is bookmarked in the SET field. Then you test
whether the number is greater than one million. If it is, divide it by
one million, then get the integer of this result for the words in
millions. Next, determine the remainder and get the text for it.
Note: The line breaks in the code section are for readability purposes, only! The entire field code should be created with NO line breaks.
For those not familiar with working with field codes in Word:
Insert the field brackets using { } using Ctrl+F9; you may not type them in any other way!
Observe the single spaces around operators such as =, >, <
Use Alt+F9 to toggle between field codes and field result
Click in the field (set) and press F9 to force the field result to update
A web form collects data on students in a band organization at school. The form data is fed into a google sheet that then populates a merge template and the merged forms are emailed to the recipient. A parent needs to print, sign and turn in the forms. There are hundreds of kids in this band and at registration time when the forms are turned in it is easier to sort all the papers in the stack if you have a short sort number in the corner... Volunteer kids don't apply alphabetization well. I'm trying to create a formula that will give me that sorting number to merge onto the header of each page of the PDF they receive after submitting the form. I want it based on last name and then first name and be able to create that number (in the google sheet) on the fly because the merging happens almost instantly when the user submits the form. Hence, an excel type formula is desired that will result in a number representing the kids name. I'd like for each number to be unique but some names are the same for the first few letters, also some names are only 2 characters long. I tried making A=10, B=11, z=35 etc. (so all are 2 digits) So, using only the first 3 characters, Bob Jones would = 192423112411 - hardly easy to sort the paper at a glance and it doesn't really differentiate between Bob Janes either. 4 digits is preferable. I also looked at =code() formula and it came out with long numbers too. Any advice is appreciated. Thanks!
Side note: What method do spreadsheets use to sort text? Do they weight the characters or what? Before I got the automerge thing to work I assigned each kid in the list a number higher than the one below and lower than above (on the sheet), then did the merge.
One option is to:
sort the name list alphabetically
add a sort number column, and put a =TEXT(row(),"0000") formula to generate a unique ID
on the merge spreadsheet, use a VLOOKUP function to retrieve the unique ID for that specific name.
First off, that wall of text was kind of hard to read through. Please try and do a little formatting so the people trying to help you can easily follow what you're trying to convey.
Personally I would suggest a hyphenated system. First initial of last name converted to a number, followed by a hyphen, followed by the first two letters of their first name converted to numbers.
Bob Jones becomes 11-1956 assuming you differentiate between upper and lower case, or 11-1924 if you convert everything to upper case, which I guess makes more sense.
You could use this VBA function to convert names to a system like that:
Function ConvertToIndex(strInput As String) As String
Dim strLast As String
Dim arrName() As String
Dim strFirst1 As String
Dim strFirst2 As String
arrName = Split(strInput, " ")
strLast = Mid(arrName(1), 1, 1)
strFirst1 = Mid(arrName(0), 1, 1)
strFirst2 = Mid(arrName(0), 2, 1)
ConvertToIndex = Asc(UCase(strLast)) - 55 & "-" & Asc(UCase(strFirst1)) - 55 & Asc(UCase(strFirst2)) - 55
'MsgBox ConvertToIndex
End Function
Thank you Tim, Nutsch and Mad Tech for your responses. I appreciate your input. Sorry the paragraph was so long, I get wordy. Because the members get their merged PDF sheet immediately after submitting I need the number to be based on the name as soon as it's entered, not after the fact; so I was looking for a formula that would reside in the sheet. Interesting VBA function too though. I'll settle for numbering them afterwards, maybe when the sheets are turned in. By then I'll know all who are in the band and can assign numbers like before. Thanks again!
I'm trying to create a Crystal Reports formula field (to calculate the percentage change in a price) that will return "N/A" if a particular report field is null, but return a number to two decimal places using accounting format (negative numbers surrounded by parentheses) if it is not.
The closest I have been able to manage is this:
If IsNull({ValuationReport.YestPrice}) Then
'N/A'
Else
ToText({#Price}/{ValuationReport.YestPrice}*100-100, '###.00', 2)
However this represents negative numbers using a negative sign, not parentheses.
I tried format strings like '###.00;(###.00)' and '(###.00)' but these were rejected as invalid. How can I achieve my goal?
I think you are looking for ToText(CCur(#Price}/{ValuationReport.YestPrice}*100-100))
You can use CCur to convert numbers or string to Curency formats. CCur(number) or CCur(string)
I think this may be what you are looking for,
Replace (ToText(CCur({field})),"$" , "") that will give the parentheses for negative numbers
It is a little hacky, but I'm not sure CR is very kind in the ways of formatting
if(isnull({uspRptMonthlyGasRevenueByGas;1.YearTotal})) = true then
"nd"
else
totext({uspRptMonthlyGasRevenueByGas;1.YearTotal},'###.00')
The above logic should be what you are looking for.