Is there any way to automatically force number of decimal places in an org-mode spreadsheet? So that 42 would be changed to 43.00 when I move to the next field?
Also, is there automatic formatting for thousands separators?
If you want a field to auto-format when changing to the next one, you would need to use the auto-update row header # to indicate that fields in that row should auto-calc whenever TAB S-TAB or RET are pressed in that row (see Org-Manual).
Then if you include as a formula for that cell (I'm assuming that if you are wanting to enter the value manually you will not have a formula affecting that cell usually) that contains (for your 42 -> 42.00 example)
=$0;%.2f
Information before the = sign can be cell or column references depending if you want the formula to be applied to a single cell or to the entire column. (This is mentioned here)
I wasn't able to find any reference to thousands separators in org, it might not be possible at the moment.
This link on Formula Syntax for Calc shows the various options for org-calc-default-modes, which will allow you to change the display format and precision.
Does this help you in any way?
(setq org-calc-default-modes '(calc-internal-prec 12
calc-float-format (float 9)
calc-angle-mode deg
calc-prefer-frac nil
calc-symbolic-mode nil
calc-date-format (YYYY "-" MM "-" DD " " Www (" " HH ":" mm))
calc-display-working-message t))
Related
I'm writing a data-sync/merge solution in FileMaker where I have two data sources and compare/merge them.
That means I have a number of tables and each with a number of fields.
I have for a testing field built my logic and a layout so that FM shows me when the local and remote data source are different and shows me two buttons to let me choose which data to merge into the other set.
I could, of course, manually replicate all the formulas and buttons for all fields in all tables, but that would be insane. Is there a way to tell FileMaker "use this layout and script steps on the buttons for all fields, changing the names of the fields as you go" ?
Or, in other words, I have two fields and two buttons. Let's call them DataA::field and DataB::field. I have a layout that shows them side-by-side. That layout has two buttons with attached logic to show the buttons only if the field values are different. Button A has a "single step" formula that says "set field value of B to A" and button B has a formula "set field value of A to B".
Is there a way to replicate those buttons and their logic to all the fields in my table without doing a lot of manual work ?
The answer is YES!
You need...
fmWorkMate
[Makes your FileMaker work]
fmWorkMate is a free Power Toolbox for FileMaker Developers from www.mrwatson.de (that I have written over the last 10 years or so).
I use fmWorkMate myself to do exactly what you are doing! In my case I'm syncing fields between tables of my FileMaker solution and embedded ESS tables, but the process is the same... make one field / bit of code... and then automatically generate ('multiply') the rest.:-)
So, how?
First up download and install fmWorkMate - This is actually the trickiest part of the process, since the latest version is yet to be published (and I will correct this once published)
If you use Mac OS < Catalina you can download the fmWorkMate Bundle from the downloads page
If you use Windows you'll need to download the old Windows version from the downloads page
If you have anything else, or have any troubles, contact me, and I'll get the tool out (at last) or to you (at least)
Here are several examples to illustrate how you can use fmWorkMate to do what you wish:
The above here does not answer the question directly, rather shows how to replace fields A and B with fields C and D.
The examples are nonetheless useful and illustrative as they stand, and the techniques build on each other.
I have added example 4 as the full answer to the question below.
Example 1: From your two Buttons with A and B, create two similar buttons with C and D
In Theory:
Copy your buttons out of FileMaker (CMD+C / ctrl+c)
Convert the FileMaker objects to editable XML with fmCheckMate
Open fmCheckMate
Open fmWorkMate
Choose the fmCheckMate tool (or press CMD+2 / ctrl+2)
Press the button [Convert Clipboard FM ⭤ XML]
Or press CMD+2 / ctrl+2
Or press CMD+OPT+C / ctrl+alt+c)
And if you are not automatically changed to the XML editor view...
Press the edit button (or CMD+3 / ctrl+3) to change to the XML-Edit view
Or set up fmCheckMate to always switch to the XML editor:
fmCheckMate > Settings... > XML editor > Small editor)
Find and Replace text in the XML as needed
Replace field A with field C
Click in the [F]ind field (or press CMD+F / ctrl+F)
Type the name of the field you want to change A
Click in the [R]eplace field (or press TAB or CMD+SHIFT+F / ctrl+shift+F)
Type the name of the field you want to change to C
Replace all occurrences:
Press CMD+OPT+A / ctrl+alt+A
Or (on newer versions of fmCheckMate) Press the [R] button
Or (on older versions of fmCheckMate) Hold ALT and press the [R] button
Replace field B with field D
Repeat with B and D
Convert back to FileMaker objects
Press the [-> FM] Button (or press CMD+OPT+V / ctrl+alt+V)
Paste into FileMaker (CMD+V / ctrl+V)
Voilá!
(Or rather - oops - did we break it?)
In Practice:
For the particular example you have given - using only one-letter field names A and B - the above will break the XML and not work - because the search and replace is across the entire XML, and the letters A and B appear in various places throughout the XML and replacing them will make the XML unreadable.
However, 99.9% of the field names you will actually be replacing will be quite unique and it is turns out to rarely be a problem.
For example, if your fields were named Previous value and Current value and you wanted to change them to Previous event and Current event that would be no problem at all.
Note, however, that just replacing value with event would (probably) break the XML as well, since value is (highly likely) the name of an XML attribute too. In general: Avoid using single word search words like name, id, Layout,.
[And, of course, the table names DataA and DataB would work fine as they are unique/non-conflicting with XML tag and element names.]
Example 2: Multiply a bit of code for multiple fields
Let's say you have a list of 10 fields you want to sync:
CustomerName
Company
Street
HouseNumber
City
ZIP
Country
Item
Quantity
UnitPrice
How can we produce code for these 10 fields in a fraction of the time?
Write the code for your first field
Multiply your code
How?
First prepare fmTextMultiplier:
Start fmTextMultiplier
Open fmWorkMate
Choose the fmTextMultiplier tool
If necessary press [New] (CMD+2 / ctrl+2) to get an empty record
Paste your field list into the empty Replace field
=> Note: The first line appears in the search field
Press the button [Don't duplicate original]
=> The first line is removed from the replace field
=> fmTextMultiplier is ready to go:-)
Then
Create some code for field 1 - e.g. the field named CustomerName
Multiply the code
Copy the code out of FileMaker (CMD+C / ctrl+c)
Paste the XML into fmTextMultiplier
Click in the fmTextMultiplier Text field
Select Edit > Paste FileMaker Clipboard -> XML (or press CMD+ALT+V / ctrl+alt+V)
Click [Multiply Text x Values] (or press CMD+5 / ctrl+5)
Click [-> FM] (or press CMD+6 / ctrl+6)
Paste your code back into FileMaker
Check + tweak your code as necessary
For example, you might want to correct the field data types.
The best thing is, this same method works for field definitions, layout-fields, buttons, script steps, scripts, whatever!
Once you have set up fmTextMultiplier once you can use the same multiplier function to multiply all the different bits of code around the fields.:D
Example 3: Generating a Series of Fields
Say you are building a calendar and need a series of fields to hold the days:
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9
Day 10
Day 11
Day 12
Day 13
Day 14
Day 15
Day 16
Day 17
Day 18
Day 19
Day 20
Day 21
Day 22
Day 23
Day 24
Day 25
Day 26
Day 27
Day 28
Day 29
Day 30
Day 31
Day 32
Day 33
Day 34
Day 35
Day 36
Day 37
Day 38
Day 39
Day 40
Day 41
Day 42
Gee, this is going to be hard work!
Nope!
We shall use fmTextSeries to generate the series automatically and fmTextMultiplier to multiply the Day 1 code.
Generate the list (series) of field names you need using fmTextSeries
Start a fresh fmTextSeries
Open fmWorkMate
Choose fmTextSeries tool
Press New if necessary
Enter the following values into the dialog and press OK
Text: Day 1
Times: 42
Ìncrement: 1
=> The series is already on your clipboard, ready to paste!
Prepare fmTextMultiplier
Go back to fmWorkMate (via the standard 'back' navigation):
Click the mrwatson logo
Or press CMD+1/ ctrl+1
Start a fresh fmTextMultiplier
Choose the fmTextMultiplier tool
Press New to start a new multiplication
Paste the generated field names into the Replace field
Choose [Don't duplicate original]
Multiply your code as in Example 2 above
And repeat for any other such fields - or indeed for any code you need (e.g. Day 1 Event Summary field, Calendar Reset script, Calendar picker layout, ...)
Example 4: Changing direction of Set Field[ DataA::field ; DataB::field ]
So,...
You have a script step (or a button with a script step - or even multiple buttons/steps) that sets 'field A' to 'field B' (or, in your case, a field in table DataA to a field in DataB)...
And you want to change the direction?
Easy! Use a fmCheckMate XSLT transform to swap the source and target fields around!
How?
Additionally to fmWorkMate and fmCheckMate (see above) you'll need the fmCheckMate XSLT library:
This is in the fmWorkMate Bundle from the downloads page
Or can be downloaded from MrWatson's fmCheckMate-XSLT GitHub repo
Once you have copied the fmCheckMate XSLT folder to your documents folder:
Copy the buttons (or script steps)
Convert to XML using fmCheckMate (see above)
Press the [T]ransform button
If this is the first time using fmCheckMate-XSLT the library is loaded
Note: In some (old?) Versions of the library + tool you may see loading errors here - these can be ignored as they are caused by some badly formatted XSLT files, that have no bearing on the further procedure here.
Find and perform the desired transformation
Either in list view
Browse to or find the Swap Set Field Target And Value function
Clicking the function name performs the function
Note:
Clicking other fields filters the list, so you can reduce the list to browse by
Clicking Change to show only Change functions
Clicking Script step to show only the Change Script step functions
Clicking the headers sorts the column
Or in tree view
Click [Change]
Click [Change > Script steps]
Click [Change > Script steps > Swap]
Click [Change > Script steps > Swap > Set]
-...
Click [Change > Script steps > Swap > Set > … > … > Value]
You can change views with the [View] button
Convert the XML back to FM
Paste into FileMaker
Lol! The direction has been magically changed!
Example 5: Multiplying code using TWO separate field lists
You haven't asked for this directly, but this example may save you having to ask another question.
If your FileMaker-fields and SQL-fields have slightly different names, fmTextMultiplier can deal with that too.
Say you have these FileMaker fields (in your DataA table)
CustomerName
Company
Street
HouseNumber
City
ZIP
Country
Item
Quantity
UnitPrice
And these SQL fields:
customer_name
company
street
house_number
city
zip
country
item
quantity
unit_price
And on your layout you have the two fields with labels next to each other:
CustomerName [CustomerName] customer_name [customer_name]
You can multiply these using fmTextMultiplier by using two columns:
First, you need the two columns separated by tabs (or whatever)
CustomerName customer_name
Company company
Street street
HouseNumber house_number
City city
ZIP zip
Country country
Item item
Quantity quantity
UnitPrice unit_price
Set up fmTextMultiplier like this:
Start fmTextMultiplier
Opn fmWorkMate
Choose fmTextMultiplier tool
Press [New] to start a fresh new Multiplication
Paste the above text into the Replace field
Set the Split Values # char/textfield to {{TAB}} (or your chosen delimiter)
Choose [Don't duplicate original]
Then you can multiply your code in four easy steps
Copy your code in FileMaker
Multiply it in fmTextMultiplier - as described above
Paste it into the Text field
Click in the field
Select Edit > Paste FileMaker-Clipboard -> XML
Click [Multiply Text x Values]
Click [-> FM]
Paste the code back into FileMaker
Organise the multiplied objects in your layout
OK, so step 4 is not that easy because all of the multiplied layout objects end up in a big pile on top of one another, which is a real pain to pull apart - if you started with 4 separate layout objects, that is.
On the other hand, if you...
Group the layout objects together before you copy them
You can then just
Paste the pile of objects into FileMaker
Align them horizontally and vertically on top of the original group of objects
Click somewhere to deselect the new objects
Click on the top object
Move it down the layout to the correct position
You can calculate the position = orig_top + height_between_rows * (total_number_of_rows-1)
Select all the objects - including the original one
Choose Arrange > Distribute > Vertically
Et voilá... all the rows are in exactly the correct position!
Example 6 - fmTextConverter
There is an also a tool for performing multiple conversions to a text, fmTextConverter.
So If you have some code that operates on your FileMaker-fields, and you want the same code to do the same to your SQL-fields, you can simply
Set up fmTextConverter
Open fmWorkMate
Open fmTextConverter
Press [New] to create a new text Conversion
Paste the FileMaker-field-names in the Search field
Paste the SQL-field-names in the Replace field
Then
Copy your code out of FileMaker
Convert with fmTextConverter
Paste your code into the Text field as XML
Edit > Paste FileMaker Clipboard -> XML
Press [Convert text now]
Press [-> FM]
Paste it back into FileMaker
Note: If one of your field names is a substring of another field name then the substitution will go wrong, if the substring is converted first.
fmTextConverter highlights this problem and offers a sort button, which sorts longer strings to the top, ensuring that the substring is never converted first!
Note too that fmWorkMate is highly optimised for efficient batch work - there are lots of keyboard shortcuts and settings to make repetitive work efficient.
I have a spreadsheet with existing date values that I'd like to convert from MM/DD/YYYY to DD/MM/YYYY format. Is there any way of doing this?
The spreadsheet comes from a csv file from someone else that i have opened in calc.
Select the cells with the dates and in Cell -> Format, choose the date format you wish (DD/MM/YYYY)
Making sure the cells are selected, go to Data -> Text to columns choose "Separated by" and "Tab" and click "OK"
Cells should now have the desired format
Cut (or copy then erase) all values from the column (CTRL + X).
Choose Edit -> Paste Special -> Unformatted text (MAJ + CTRL + ALT + V).
On "Fields", click on your column, then select "Date (MDY)". It is important here to select the format the data currently is, NOT the format you want it to be.
If date is still not OK, you will need to follow this additional step (response above from #cybernetic.nomad):
Select the cells with the dates and in Cell -> Format, choose the date format you wish (DD/MM/YYYY).
NB: Note that my LibreOffice Calc is not in english so I am not 100% sure about the option names.
You select the cells to format, then you press Ctrl-1 (or choose "Format" - "Cells..." from the menu, or any other way) to open the dialog to format cells. There is a text field "Format code" where you enter "DD/MM/YYYY" without the quotation marks. Click "OK".
If that does not format the date like you want, the value in the cell is not interpretable as a date. Investigate the cell's value, you might have a text marker (a single apostrophe ') as the first character.
To check this out and experiment with the formats, choose "Insert" - "Date" from the menu. It puts the current date into the current cell.
Disclaimer: Since my Calc is not set to English, the names of menus and their entries might be different. I just guessed how they could be named.
EDIT:
If you can't change the cell format because the date is constantly recognized as "text", you might like to try this:
Insert a column right from the date column. This produces in your case the column O. All columns right of it are pushed to the right.
Put this formula in cell O2 on the right of the first date text:
=CONCATENATE(MID(N2;4;3);MID(N2;1;3);MID(N2;7;4))
It takes snippets (MID()) from cell N2 and concatenates them in the new order. Details of the functions are in Calc's documentation.
You will need to adjust N2 to the correct cell reference if it is not the cell directly left of the cell you're entering the formula.
Put the cell cursor on N2.
Press these key combinations in sequence to mark a deep enough range of cells in column O: Control-Down, Right, Shift-Control-Up. The cell cursor will be on cell O2 now, and the range below and including it is marked.
Now press Control-D to copy the formula in O2 into each cell in the range.
Now you will have a new column O with the text of N, but exchanged characters. The values are still "text", though.
If you like, you can shrink the width of column N now, or hide it.
Example:
Input wanted: DD/MM/YYYY (31/12/2021)
Input accepted: MM/DD/YYYY (12/31/2021)
First add new Date type
Go to Format --> Cells
In "Category" select "Date"
In "Format code" write the input wanted. In this case DD/MM/YYYY
Press the green check
Second format style
Go in the cell where you want to add the date
Write the date in the wrong format. Example: 12/31/2021 (for 31st December 2021) even if you want 21/11/2021
Select that cell and press CTRL-X. The text should disappear
Select that now empty cell and do: Edit -> Paste Special -> Pase unformatted text
The date should be there in the wrong format
Select that cell with the wrong date and do: Format --> Cells
In "category" select "date" and double click on the newly added date type (aka DD/MM/YYYY)
I am using a 3 way formula to put notes below the group footer of my Crystal Report. Please see below example for illustration
1. Text
a. Text
b. Text
2. Text
a. Text
b. Text
3. Text
a. Text
b. Text
c. Text
I was able to put the numerical series using a variable and increment it by 1, however in letters, I have seen a code to something like
chrw(96 + i) //where i is 1 based
But that wont work because my text interpretation is on HTML, are there alternatives? or conversion of the code for it to take effect in my formula.
chrw(ascw("`") + (var2 := var2+1))
the code above worked for me!, just set the variable var2 and initialize to 0 value. Do some conditioning to create an indention effect.
I need to add .jpg at the end of all he cells in one or more columns
9788895249971 into > 9788895249971.jpg
9788867230129 into > 9788867230129.jpg
9788867230273 into > 9788867230273.jpg
9788867230280 into > 9788867230280.jpg
Detailed step-by-step instructions are much appreciated since I am very new to Calc.
Thanks
Do you need to do this once or is this going to be a repeated task every week/month?
If it is something you need to do just once, here is what you can do:
Next (right) to the column where your numbers are open (insert) a new column.
Assuming the following: Numbers are in column A, New column is column B.
In this new column B in the top cell (B1) write:
=A1&".jpg"
Now copy B1 all the way down to the end. In B1 type [Ctrl]+c then Hold [Shift] and hit [PgDn] until the end then press [Ctrl]+v.
Highlight Column B, [Ctrl]+c, then [Edit] [Paste Special] values only (No formula's) this freezes the calculated data.
This is just another option,
just click the function wizard and select concatenate, in that enter which column you want to enter as text1 as and second column in text2. Then when you click OK you will get an concatenated column like below image
so in the C column you will get as a1.jpg.
For those who continue to find this question (as I did):
This can be quickly done using regular expression option of find and replace. (I don't know what version of Calc introduced regex searches, but 6.2.4 has it.)
If you only want to update some non-blank cells on the sheet, select them.
Choose Find and Replace.
On the dialog, fill in the following:
Enter $ for the Find value. ($ means end of line in regex, or in this context end of cell value.)
Enter the desired suffix (.jpg in the question) for the Replace value.
Check Regular Expressions under Other Options
Check Current Selection Only under Other Options if you want to limit to the cells selected in step 1.
Uncheck All Sheets unless that is what you want.
Choose Replace All
This will update the values in-place and does not require any additional columns or formulas.
There's a much more elegant way to do this that doesn't require sacrificing cells just to hold data types, and can be scaled to work with one cell or a large chart range.
Add both pieces of data into the =CONCAT() function
Make sure to use CONCAT instead of CONCATENATE, as `CONCAT accepts cell ranges and is more dynamic.
Open the Function Wizard on the cell in question, and build the following function:
=CONCAT(<your_data>," <suffix>",...)
# Make sure to add a space before the suffix so it appears in the cell.
# You can use this with as many input variables as required letting
# you add as many strings, formulas, or numbers together.
The result should be something like this. In my example, the cell in question is the final value of Ethereum on a balance sheet:
The above example was an easy one, since it was being used as a test, all my summed values were ints, if I had floating point numbers, they would run away to max decimal places (not very pretty).
The function will drag out and expand intelligently to other cells like any other formula.
Adjusting accuracy of floating point values inside a CONCAT function
Sometimes, adding a cell results in a rounding problem, or an extreme amount of decimal places. You can further nest your function using ROUND(<your_data>,<decimal_places>)
Your function would look like this:
=CONCAT(ROUND(<cell_range>, ".jpg")
In your specific case, you don't need a space in the second argument as you want to append .jpg directly to the end of the string.
`
Using Macros to automate the entire process
This is extremely repeatable, and using the Macros feature, you can automate these to make much more simplified functions that allow you to enter just the variables you need, while the macro does the work in the background.
Based on Emmanuel Angelo R.’s answer, I would advice learning to differentiate between fixed cell references and dynamic ones. The following applies:
Cell A1 contains the suffix you would like to add, e.g. ‘.jpg’
Row 2 contains headings, e.g. B2 = ‘Old Filename’ and ‘New Filename’
Cells A3:A¹ contain your filenames
Cells B3:B contain you concatenation formula
In cell B3, type =concatenate(A3;$a$1).² If your locale requires comma as separator, replace my semicolons with commas. Copy cell B3 by selecting it and pressing Ctrl + C. Move the cursor to cell A3, press Ctrl + ↓ (down arror on your cursor keys); this will move you to the bottom of the list of file names. Move your cursor right, then press Ctrl + Shift + ↑; this will select all cells up to the last cell with contents (the one you just wrote your formula in). Press Ctrl + V to paste your contents.
Adding dollar signs in front of your row/column coordinates, will lock that coordinate when pasted. Say you had a list of file types in cells b1–z1 (e.g. jpg, jpeg, tga, bmp, png et c.). An easy way to create the formula would then be by first typing it in cell B3 as =concatenate(A3;B$1), then paste it to every cell till the end of your file names list (cell z3); these cells would then read …A3;b$1, …A3;C$1 et c. When copying it for all the rows below
You could select the entire range of cells with formulas in row 3 and run a search and replace, replacing all instances of ‘A3;’ by ‘A3;$’, effectively inserting a dollar in front of all the cell references, allowing you to, should the need arise, copy it horizontally as well as vertically (the latter being covered by the $ in front of 1).
¹ This means cells from A3 and however far down your sheet goes
² Strictly speaking, it is only necessary to type it as a$1.
I have a field which is a Double. For display on a the report, if that value is negative, then I need to reverse the number by multiplying it by -1. The result should be formatted like this: "(1,000)" (notice no "-" sign). How can I do this in Crystal? I was using a Display String formula to try to do this since the "Reverse sign for display" option doesn't work for me (because it needs to be a formula for other reasons).
So far I have:
if {columnName} < 0 then
"(" & ToText({columnName}, "#,###", 0) & ")"
else
"(" & ToText({columnName} * -1, "#,###", 0) & ")"
But this gives me something like this: "(-6,500)", and I need to get rid of that pesky minus sign.
Edit:
I implemented a formula field like this:
-Abs({columnName})
Then selected the format that looks like (1,234) from the format list as Craig answered below.
Crystal Reports supports 'accounting' formatting w/o much effort:
right click field, select Format Field...
select Number tab (if not selected)
choose the style that resembles '(1,123.00)'
** edit **
You can also apply this formatting to a formula field.
I have accomplished my requirement this way< I have added a formula and assigned sum of the required field then I set its Format (12,34.00) also i have removed Dollar sign.
Formula = replace(totext(Sum({myfield}) * -1),"$","")
I have face same pro blame but it OS specific . ON windows xp no any formatting problem but above xp this issue face. Use following formula in Display Formula after removing all formatting .
Replace(Replace(Replace(ToText (CurrentFieldValue, "##,##,##,##0.00", 2),"$",""),"-",""),",","")