Hi – Wondering is there a way to add formatting to a calculated field – – e.g., to add the “$” in front of a computation or a “%” after a computation? Applicable to either adding this with a cue on the home-screen for a new activity (e.g., I am computing rolling 12 months sales, and want it to look like a dollar amount; or on item ledger entries, computing a quick gross profit and want the % to appear). Would also be interested in understanding if conditional formatting could also apply, or if the computation can only be applicable related to an if statement – – for example, if the entry type = sale, then compute the amount.
There is, but you’re losing the right justification of the field.
The solution is to create a text-based calculated field and use the FORMAT command, something like this: (Format converts a value in to a Text)
‘$’ + FORMAT(<here you place your numerical calculation>,0,<formatting>)
or perhaps:
FORMAT(<here you place your numerical calculation>,0,<formatting>) + ‘%’
Read more about FORMAT here:
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-format-joker-integer-string-method
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-format-property
You have to change the type for the calcuated field from Decimal to Text for this to work.
Thank you — that worked!
However, how would this be acheived on the “create new fields” page? I am following one of your videos (which is helpful!) from Youtube and creating a trailing 12 months revenue item on my activities cue / home page. Right now that is a FlowField – – that is setup to Sum, Cust. Ledger Entries, based upon a filter for the posting date + a filter on the document type. Here I want to get a “$” to appear in front of the amount it is summing. But if I change the “Type” from Flowfield to “Text” it seems like I lose my ability to tell the system what I want to sum.
You can’t, BC doesn’t support the $ prefix. You’ll have to create the dual solution you have now, field+calculated field.
Are you saying that when I am editing the expression, inside of Simple Object Designer, I can use what you are referencing above? because i am trying and seem to be getting an error that says: “Syntax error: Line 2 – Type mismatch (Decimal vs. Text)”