Currency summation in Lotus Notes - lotus-notes

We have designed the LN forms with editable fields.User enters the amounts in the editable fields. We are converting the these amounts to currency using 'CCur'. The actual issue is user enters the amounts with decimal separator either as comma(,) or dot(.). When converting the amounts to currency it is not considering the decimal and thousands separator.
Example:
User enters amounts as below: Amount1 = 2090,Amount2 = 1500,90 and Amount3 = 800
In the current case the TOTAL AMOUNT is calculated as 152980.00 which should be 4390.90
How can I achieve this? Do we have user specific settings in LN which automatically takes care such things?
Regards,
Kishore

It sounds like your currency formats may not be set up correctly, and thus the locale of the client being used to enter the value 1500,90 is one that assumes the comma is a thousands separator, and the period is a decimal separator.
Here is one section of the documentation to check-out. You may need to confirm the field settings on the form to see if a custom currency format has been specified. Otherwise, see what the user preferences of the client says

For this question, I am not clear that why are you using comma as a decimal separator, I guess that it is not a formal way for storing the currency value. I can understand. this is your requirement. Just Take this as a suggestion. Okay We have the field property, First you change the field type as Number. And set the field control property, Number format is as currency and Change the User preference as Custom. There you can find two kind of settings enabled. Here you change the thousand separator into a different symbol. But I guess that you can not give multiple separator for decimal or thousands. Also If you give the same symbol for both things. It will be conflict.
My opinion- Based on your requirement, You do replace the comma with dot before applying the Ccur().

#Ramkumar: I don't agree. Set the field settings to Numeric and "User settings", not "custom". The users need to use the correct decimal point, if they are in a country where a period is used for decimal point, they use that, if they are in a country where they use comma as decimal point, they use that.
Kishore, you could add a field validation on the numeric field to make sure the value is numeric.
Use #IsNumber for this.

Related

Reformatting domestic/international phone numbers with various formats in Excel (VBA or Functions)

PROBLEM:
hey y'all, i have a large dataset of both domestic and international phone numbers formatted in various ways that i need to convert to a particular format based on specific criteria.
example of current phone number formats in the dataset:
###-##-##-####-####
+##-##-####-####
(###) ###-####
+## (#) ## ### ## ##
##-##-######-#
as you can see, the phone number formats vary greatly and there are many more examples that i did not list. i work with datasets averaging 1000+ rows.
what i try varies depending on how much data cleanup i need to perform, but below are some of my current methods.
Approach 1: Manually editing
i have attempted manually updating the phone numbers to my desired formatting. however this is time consuming and leads to user error.
Approach 2: CTRL+1 "Format Cells"
i start by sorting my list of numbers. then follow ctrl+1 > Number > Custom to format the following:
domestic as 000-000-0000, UK as +##-##-####-####, etc.
the issue with this method is that the numbers are stored as formatted "Custom" values. so any special spaces or characters (i.e. "-", "+") do not exist within the string. meaning that i cannot import into my crm.
i have attempted to manually add "'" at the beginning of each formatted phone number, but it removes the special formatting. e.g. ###-###-#### just becomes '##########.
Approach 3: Functions
i have tried using the following functions on domestic phone numbers, but they only work if formatting follows ###-###-####. which is not always the case for the data i work with.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")","")," ",""),"-","")
or
=MID(A1,2,3)&MID(A1,7,3)&RIGHT(A1,4)
Approach 4: Macro
i've attempted recording macros, but this does not work properly since the length/formatting of a cell value and size of a sheet always varies.
Approach 5: VBA script
i am currently exploring various scripts. there are a ton of examples on stackoverflow, but most presume clean data formatted as (###) ###-####. so the scripts do not work for me.
this post was helpful as a first step to removing all special characters from cells: Phone number format
but again, only applies to certain types of formatting.
DESIRED OUTCOME
i undergo this process various times a month and am hoping somebody can help me optimize my approach.
i need domestic numbers to become ###-###-#### and international phone numbers vary, but the UK would look like +##-##-####-####. i need these characters to exist within the actual string of each cell, otherwise my crm will not accept the phone numbers.
I'm not entirely sure, but maybe this gets you going:
Formula in B1:
=MAP(A1:A5,LAMBDA(x,LET(y,CONCAT(TEXTSPLIT(x,TEXTSPLIT(x,ROW(1:10)-1,,1),,1)),TEXT(--y,SWITCH(LEN(y),10,"###-###-####",12,"+##-##-####-####","0")))))
MAP(A1:A5,LAMBDA(x - Loop over a given dataset;
LET(y,CONCAT(TEXTSPLIT(x,TEXTSPLIT(x,ROW(1:10)-1,,1),,1)) - Part where each input gets cleared into just pure numeric characters;
TEXT(--y,SWITCH(LEN(y),10,"###-###-####",12,"+##-##-####-####","0"))))) - Now use SWITCH() to test against the length of the numeric input. If 10 or 12 we kind of know what format we like, the last parameter is the 'standard' format. But obviously you could start adding checks. In the samples given, you'd want to include options for length 11 and 15.

Formatting of number with currency symbol

I am values in Excel with format (e.g. ₹18.05 with custom format as [$₹-ur-IN]#,##0.00. There are times when the values are displayed as ₹0.00. In the cases the value happen to be ₹0.00, I want to display blank cell. Please let me know what changes are required in custom format to achieve the same.
Thanks
The format is specified as
<Format for positive values>;<Format for negative values>;<Format for zero values>
You can just provide no format for the case where you have a zero:
[$₹-1FAE37]#,##0.00;-[$₹-1FAE37]#,##0.00;
depending how you want to handle any negative values.
Semicolon (;) may be a different character in your locale.

Save number format by default in Excel

I would like to save number format with comma delimiter as default in Excel.
So number 123456.78 will always look like 123,456.78
How can I do this ?
Excel general number formatting is based on your locale. This contains a "Digit grouping symbol", filling this is will change your format accordingly.
Be aware this is not only done for Excel, but for every application on your computer, based on this format.
Home/Styles: Right click on Normal and select Modify
Change the Number style
from General either to Number + use thousands separator
or, if you want to use Scientific notation when over a certain amount, perhaps
[<100000000]#,##0.00;General
or whatever you want.

Importing Excel to Access: Date be field name for Access table

I was trying to import an Excel worksheet into Access table and the worksheet had specific dates(E.g. 12/4/2017) as headers for columns.
And when i tried to import to Access, Access did not allow me to import that worksheet into table as "12/4/2017 isnt a valid field name"
Is there other ways to import the worksheet or work about this?
Thanks
Names of fields, controls & objects in Access:
Can be up to 64 characters long.
Can include any combination of letters, numbers, spaces, and special characters except a period (.), an exclamation point
(!), accent grave (``) or brackets ([ ]).
Can't begin with leading spaces.
Can't include control characters (ASCII values 0 through 31).
Can't include a double quotation mark (") in table, view, or stored procedure names in a Microsoft Access project.
(Source)
Date and time values in Excel are stored internally as a 64-bit floating point number. The value to the left of the decimal represents the number of days since December 30, 1899. The value to the right of the decimal represents the fraction of a day since midnight.
For example:
12:00 Noon is stored as 0.5.
1.0 represents midnight on January 1, 1900.
2.25 represents 6:00 AM on January 2, 1900.
Your example date 12/4/2017 would be stored as 43073.
Interpretation of datetime's depend on customization of regional settings according to Microsoft (not necessarily the country's government standard date format). For example, I live in North America, so by default, Excel would interpret 12/4/2017 as a date.
However, for various reasons, I prefer a date format of YYYY-MM-DD (technically named "ISO 8601"), so I changed the format in my Windows Settings. Therefore, when I enter 12/4/2017, Excel does not recognize it as a date, so it is stored as text, yet when I enter 2017-12-4, Excel knows to store it as a date.
Regional settings aside, I suspect that your field names may have times attached to them (even if they aren't formatted to display as such).
If the cell you'd like to use as a field name actually contains:
April 12, 2017 6:00 AM
which, if formatted as M/D/YYYY, "hides" the time, to display as:
12/4/2017
even though it is actually stored internally as:
43073.25
Given the Access field names can't contain a period (see above), Access becomes "confused" with the fraction of a day (.25).
Make sure your dates to be used as field names don't contain times.
You could:
Format the row that has the field names as text.
Right-click the row number and choose Format Cells.
Under the Number tab, choose Text
Use a function to remove the times:
If B1 contains a datetime you want to use as a field name in A1, you could use the Int function in cell A1 (to round the value down to a whole number):
=Int(B1)
The fraction (time) is removed but the value is still stored as a number/date.
Use a function to convert the datetime to text:
If B1 contains a date you want to use as a field name in A1, you could use the Text function in cell A1:
=Text(B1, "M/D/YYYY HH:MM")
As you can see in the image, Access allows me to use the dates as field names if they are properly formatted:
Related Further Reading:
TechRepublic: Techniques for successfully importing Excel data into Access
Office.com: Guidelines for naming fields, controls, and objects
ExcelTactics: The Definitive Guide to Using Dates and Times in Excel
Microsoft: How to use dates and times in Excel
Stack Overflow: MS Access - Date as Table Field Name
A note about Database Normalization:
Just because you can use dates as field names, that doesn't mean that you should. It is generally considered poor database design to have a field name so specific.
Perhaps your intention is to import the poorly-structured data into Access to fix this issue, but if not, you should consider storing the data in a more organized way that is conducive to database expansion and normalization.
If your data has date-specific field names:
...then the date should be added as part of the record, not as a field name:
...although this is still not normalized. Normalization is about optimizing efficiency and allowing for expansion, so perhaps the database could be setup more like:
With this method it would be database expansion and data analysis would be more logical (perhaps making it easier to find trends in Jane's troubling eating habits).
Alas, I digress. There is plenty of information available online about database normalization, to suit any experience level.
Further Reading about Normalization:
Wikipedia: Database Normalization
Microsoft: Description of Database Normalization Basics
ThoughtCo: Database Normalization Basics
Stack Overflow: Database normalization - who's right?
EDIT: (the result)
You didn't mention which method you're using to import the data from Excel to Access, which may be relevant (as there are several possible combinations). Access might handle the source data differently if your Excel data is saved in an XLSM vs XLS vs CSV, etc. Data could be imported using the New Source Data…from File interface, vs programmatically with VBA, or even other languages. Therefore, if you can't get one method working (with the dates formatted a specific way), try one of the other combinations.
For simplicity's sake, I used the built-in interface with an XLSM into an ACCDB. The result is demonstrated below:
Note that it worked even though I included times in the headers (and would work without times), since they are properly formatted as text, and First Column Contains Column Headers is selected.

Some but not all Excel numbers show as a date

I have a big .xls file. Some numbers show as a date.
31.08 shows as 31.aug
31.13 shows as 31.13 (that is what i want all columns to be)
When I reformat 31.aug to number it shows as 40768,00
I have found no ways to convert 31.aug to 31.08 as a number. All I am able to do is to reformat 31.aug as d.mm and then it shows as 31.08 and when I try to reformat it from 31.08 to number it shows as 40768,00. No way to cheat Excel using different types of cell formats.
How's your regional settings? There are some Regions where the short date is identified by dd.mm.yyyy. (Estonian, for instance). Maybe if you change the regional settings for US / UK and paste the data again it won't be changed.
Worked in a small test I did here. Hope it helps.
Internally Excel stores Dates as integer. 1 is January 1. 1900. If you entered something that Excel interprets as a date then it will be converted into an integer. I think from this point on there is no way back.
There is an setting in Options on the tab "international" where you can define your decimal separator. If you set this to ".", then your Excel should accept 30.12 as decimal number and not as date.
As pointed out by others, Excel interprets some of your data as a date instead of a number, which depends on your regional settings. To avoid this happening try Tiago's and stema's responses, they will work depending on your regional settings.
To repair your problem in a large file after it has happened without re-entering/re-importing your data, you can use something like
=DAY(B5)+MONTH(B5)/100
to convert a "date" back to a number. Excel will still display it as a date when you first enter this, but when you reformat it as "Number" now it will display the value you originally entered.
Since your column seems to contain a mix between correct numbers and dates, you need to add an if() construct to separate the two cases. If you haven't changed the display format yet (i.e. it still displays 31.Aug) you can use
=IF(LEFT(CELL("format";B7);1)="D";DAY(B7)+MONTH(B7)/100;B7)
which checks if the format is a "D"ate format. If you have already changed the format to Number, but know all your correct data is below 40000, you can use
=IF(B5>40000;DAY(B5)+MONTH(B5)/100;B5)
As suggested above, go to Control Panel - Region and Language - Advanced Settings - Numbers - and change the Decimal Symbol from "," to "."
Good luck!
The data you are pasting, is it by any chance a pivot table.
For example, like you, I am copying a lot of data into a large spreadsheet. The data I am copying is from another sheet and it is a pivot table.
If I paste normally, half will show up as numbers, which they are in the source file and half will show up as dates, for no reason, which drives me insane.
If I Paste->Values however, they will all show up as numbers, and as I don't need the pivot functionality in the destination file this solution is fine.
All you have to do is format cell.
1-right click on the cell where you want to insert the number.
2-then click on Number and select 'General' from the number menu.
Hope this will help future people with the same issue.

Resources