Questions tagged [decimal]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
22 views

Format decimal according to locale, but with fixed number of decimal places

There were many question around the topic of formatting decimals according to user's locale and rounding decimals, but I haven't seen the one that actually fits my case, so here I go. I am creating ...
1
vote
1answer
43 views

Decimals coming back as 0.00 [closed]

I have some logic in Marketing Cloud which divides the number of orders placed by the number of customers targeted for some comms (Orders_pp) but this keeps bringing back 0.00 instead of 0.04. The ...
5
votes
1answer
35 views

When Advanced Currency Management (ACM) is enabled, is there a way to bypass the default 2 trailing zeros?

With ACM enabled, it defaults currency fields to have 2 decimal places. My client is in the manufacturing industry and they require 4 decimal places. Enabling ACM is necessary for this project due to ...
0
votes
0answers
38 views

How to allow decimal input whose number of decimal places is lower than the step value of input component

I have a lightning input component with the attributes as type="number", formatter="decimal",and step="0.01". However, this seems to restrict the decimal input to be of exactly 2 decimal places. Is ...
1
vote
1answer
42 views

How to render a Currency field with decimal places as specified on the Custom field without trimming zeros in APEX [closed]

When we add a Custom field of these data types 'Currency field/ Number field/Percent' as merge fields on email template or adding the merge field on a document, trailing zero's are removed. Trailing ...
0
votes
2answers
43 views

Wrong decimal formula: I can't get the right value

I use this formula field in my apex code. But I have big troubles with it, because there should be different logic for values 0 and NULL. If I choose Treat blank fields as blanks, I'll get NULL even ...
2
votes
1answer
27 views

AggregateResult Number format in Visualforce Page

Hi all I have an aggregateResult query which is pulling correctly into a visualforce page block table. All the numbers are have 0 digits right of decimal but the values display with one 0 to the right....
2
votes
1answer
35 views

Why are my arrays with equal Number or Currency field values (from SObjects) not the same?

I am using various fields, including Number or Currency type ones, in two different object types to form a "key" to allow me to generate an "identity" that I can use in a Map in Apex code, which I ...
0
votes
0answers
39 views

locale decimal seperator for currency input-fields

We built a form with many lightning-input-fields in which you can enter values for custom currency fields. Company currency settings AND user settings are set to German. So I expect, that users can ...
2
votes
4answers
1k views

How to get the fractional part of a number in apex

I need to get the number after de decimal point. For example I have: 344.567 And I need to get in a variable 567. I've tried the next: decimal d=43.3432332343344; String s = String.valueOf(aa); ...
0
votes
1answer
261 views

Get full length decimal value of a managed field with decimal places set to 2

I have a Managed field Number(16, 2) of which number of decimal places cannot be edited. For Example, if I enter 1.2391276549 into that field, It is displayed as 1.24 (as we know that salesforce ...
0
votes
1answer
87 views

Is it possible to convert numbers from Base 10 to Base Alphabet and back again using formula fields?

For shits and giggles, I am working to create a spreadsheet application (comparable to Excel, inspired by The SCells Spreadsheet) on Salesforce.com Each spreadsheet cell will correspond to one ...
4
votes
1answer
97 views

Round Decimal and .format() it into a localized output String with more than 3 decimal places

Until today I was very happy with this utility method public static string roundNumber(decimal d, integer precision) { if(d == null) return ''; string separator = (1.01).format().substring(1,...
0
votes
1answer
174 views

Sum up values(currency) from the list

Decimal totalReceived = 0.00; List<Money_Received__c> moneyReceived = [Select Amount_Received__c,Reservation__r.Total_Recieved__c from Money_Received__c where Id =: reservationId]; for(...
0
votes
4answers
643 views

APEX Trigger Round decimal place to a specific number

I am working on a trigger that sets the price of that a customer pays us. There are requirements that I am struggling with meeting. If the decimal for the price is lower than .95 then it needs to be ...
0
votes
1answer
496 views

currency field multiplied by another number rounded down its decimals

We have a currency field which should produce a currency result with decimal points after multiplication. However, the decimal part was consistently round down to zero. All fields in the formula have ...
0
votes
1answer
288 views

Salesforce storing decimal values to 3 digits internally , inspite of only 2 decimal field permitted on field

I have a discount and currency field, While saving formula, currency field gets filed in, While saving currency , discount field should get filled in. However, The problem is , Salesforce by ...
1
vote
1answer
43 views

Is SoapType.Decimal a valid value?

Documentation for SoapType enum does not list Decimal as a member. But it's possible to compile a class which uses SoapType.Decimal. Could this be a problem if we use such code in a managed package?
0
votes
1answer
265 views

Decimals with 2 digits Salesforce

I have 4 Decimals fields with 2 digits, A, B, C and D. When I tried to multiply A*B and put them into C the C and D should be equals but they are not. What is the best practice to use the Decimal ...
1
vote
1answer
2k views

Format decimal number with thousand separator with a dot (.)

I would like to format a visualforce variable '{!TotalE}' with a thousand separator as . notation for example 123386258.00 becomes 123.386.258 I have tried examples of outputtext 'value="{0, ...
2
votes
1answer
2k views

Saving null value to decimal field using apex

I just wanted to check is it possible to save empty value or null value to a decimal field using apex. Let us take that there is a number field by name Count__c, which needs to be set as blank when ...
0
votes
1answer
39 views

Method does not exist - {List}.get(Decimal)

I get errors for the last line. Method does not exist - {List}.get(Decimal) opp.Most_Expensive_Competitor_Price__c = oppCompetitorPrices.get(highestPrice); I am trying to populate the ...
0
votes
3answers
2k views

Apex division losing precision

I am having some issues related to the precision with Decimals. Let's take a look at the following scenario: Decimal total = (5 / 3) * 3; System.debug(total) // this will print 4.9999999999999999 ...
1
vote
2answers
2k views

Invalid field count for AggregateResult:

Aggregate count error - please assist and excuse this basic mistake. I am trying to count a number from the query and then to use it in some arithmetic. Tring to get RemainingMonthsDec throws the ...
2
votes
1answer
3k views

Convert a String to a Decimal

in my code I need to put a String contained inside a map in a Decimal variable. Now I have 2 problems, the first one is the format of the String because it can contain ' , ' and ' . ' e.g. '21,31' or '...
0
votes
1answer
424 views

Decimal Number 1.00 displayed 1.0 in VF

I have Number type field that has two decimal values. I am using the same value in my VF to generate quotations. If the value is 1.08 it is reflected 1.08 in VF, but if it is 1.00 then in VF it is ...
1
vote
1answer
3k views

Need AMPScript function to convert string to decimal

In an email I have a variable coming in that is in string format (it's a price). I need to multiply that by another number, which means I need to convert the string to a number in the xx.xx format. ...
1
vote
0answers
106 views

How can I add cents (including .00) with setScale? [duplicate]

If in an Apex class I set some decimal values like so: public List<String> args = new String[] { '0', 'number', '#,###,###.##' }; public String getPrice() { Decimal amount = (lead.Price__c)...
2
votes
1answer
2k views

Number Type, Decimal Points Confusion

We have a number typed field say Min_Distance__c where we have defined, Length=1 and Decimal places=2. But we experienced that salesforce allows to save numbers with more than 2 decimal places. In ...
0
votes
1answer
55 views

Can't insert a record with Number(16, 2) field type

I've to insert, for my test method, an Invoice__c object with a value of Amount_Due__c more than 0. This field is a Formula (Number) with 2 Decimal Places field with this syntax Invoice_Amount__c - ...
4
votes
1answer
2k views

Variable does not exist: Decimal

I have the following code: fieldList = (List<Object>)JSON.deserializeUntyped('['+ JSONValueRights +']'); for(Object fld : fieldList){ Map<String,Object> data = (Map<String,...
1
vote
0answers
389 views

Add comma on input text that reference a decimal value

I have an inner class that has decimal attribute. This attribute is referenced by an input:text field on visual force. My question is how can I add thousand comma separation on this input text? e.g ...
0
votes
2answers
8k views

If decimal is null

I have a query that sometimes returns a value if the current user has a record. If they do not no value is loaded and my vf page does not show a gauge. Today, I have been tweaking the controller to ...
3
votes
1answer
318 views

“Expression cannot be assigned at line X” - Trying to incrementally increase quantity of Decimal value in an <Id,Decimal> map in a for() loop

Scenario: We have a quoting system with a child object called zqu__QuoteCharge__c that acts as the individual line items on the quote. zqu__QuoteCharge__c is also the child of ...
0
votes
0answers
438 views

Unable to convert value 'userAmount' to type 'Integer' for attribute 'maximum'

I am trying to set a visualforce gauge chart to have the maximum value be a currency field from the user record. I can get the field: Decimal userAmount = [Select ISO_Goal__c From User Where Id ...
1
vote
0answers
1k views

Number vs Percent problem

I am seeing some odd behaviour with Numeric vs Percent fields. I have two fields, on separate objects: Percentage Commission on Object A - Number(15,3) Percentage Commission on Object B - Percent(3,...
4
votes
2answers
739 views

Can Decimals be used as Map keys? [duplicate]

I have seen at least one other question where a user has had issues with using Decimals as map keys (his issue was interchangeably using ints vs decimals), but it isn't the same issue I'm having, ...
2
votes
0answers
203 views

Why sales force is rounding up Value?

Why sales force is rounding up Value. I have EnteredLoan Amount (£) 999,999,999,999,999.99. However when i am doing query on Dev. Console it is returning me 1000000000000000. How do i avoid this?
6
votes
3answers
34k views

Function to convert String to Decimal value?

I need to convert String into Decimal. the isNumeric() method is retuning false if value is Decimal. Another alternate: try { Integer x = Integer.valueOf(myString); } catch (exception e) { // ...
0
votes
1answer
67 views

How can i get decimal place upto 4

Below is my code which is giving me decimal places upto 2. But I want to get decimal upto 4. Please help IF( Final_Amount_with_exch_rate__c>= 1000000, TEXT(FLOOR(...
1
vote
1answer
162 views

Decimal field showing incorrect format

This is a very weird situation as I have never seen such anomaly. I created three Decimal fields on an Object and the data in these fields are populated by a trigger. Everything is fine when I see ...
13
votes
3answers
11k views

Decimal or double?

What datatype should I use in Apex Classes when I need to store a number with decimal places. What do you use and why?
1
vote
1answer
2k views

Convert aggregate result to decimal

I need to fetch the AggregateResult 'sett' for each Opportunity in a loop, from a map and convert them into decimals. I've seen Ariel's solution on this post but when I use it, it causes an error ...
0
votes
1answer
540 views

Pulling in currency field from Salesforce into Exact target

Wonder if anyone can help me, I am pulling in a currency field from Salesforce into ExactTarget but I have the following issue: If the currency ends with a zero (i.e. 223.00) the last digit does not ...
5
votes
2answers
534 views

Decimals pretending to be Integers when used in Maps

I came across some very strange behaviour when working with a Map with Decimal keys today. It seems like the Decimal type can't handle Integer assignments properly, but allows them nonetheless. I've ...
0
votes
0answers
200 views

Use comma sign to show precision instead of period sign in Dataloader

I am using Dataloader to upsert some records but my decimals will not load because the values are not valid. The decimal uses a comma sign to separate the whole from the precision (so for example 2,34 ...
3
votes
2answers
133 views

Is there any way to maintain a Decimal scale property without rounding for every operation?

Is there a way to maintain the scale of a Decimal across multiple operations? I thought setScale appears to be a normal set method on the Decimal class. Meaning that you can set the scale, and then ...
0
votes
1answer
7k views

Division in Apex, explain

Integer a = totalRecords.size(); //1250 decimal b = 400; integer block = a/b; //3 The actual result of 1250/400 is 3.125. Because I used integer block, I get 3 as answer. Instead of that if I use ...
1
vote
2answers
2k views

Input field for decimal property

My VF tags: <apex:column > <apex:facet name="header">Sales Price</apex:facet> <apex:inputText value="{!prod.SalesPrice}"/> </apex:column> Controller code: ...
2
votes
3answers
1k views

Why is Salesforce hiding Discount, UnitPrice and TotalPrice decimals?

I've been migrating some QuoteLineItem and OpportunityLineItem records, and I noticed an odd behavior of the Salesforce platform. First, here are the field definitions: Here, we can see that: ...