Questions tagged [math]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
62 views

Finding the average of dates using flow

I have a flow that creates a collection of dates of birth. my goal is to add them together and divide by the count to get the average date of birth. the amount of DOBs in the collection can change ...
la-Ola14's user avatar
0 votes
1 answer
120 views

Apex - Division Calculation Result Is 0? (Expected Decimal Number, Does It Follow BIDMAS?)

Just a quick question. I was trying to System.debug() a calculation I was doing: (260 / (260 - 28)) - 1 That should print something close to 0.12068965517241379310344827586207. But, my debugs were ...
User's user avatar
  • 111
0 votes
1 answer
2k views

Apex Convert Positive Currency to Negative Currency

I'm wondering if my syntax is off. My varCreditRefundAmount is a positive value and when I add it to a new transaction representing a refund, I want to convert it to a negative amount. This is what I'...
Heather's user avatar
  • 51
0 votes
1 answer
142 views

Issue with Multiplication and Division [duplicate]

Couldn't seem to find an answer to what I was looking for. If I have the below code: totalCount = 7; greenCount = 3; // Debug statement right here shows immediately berfore operation that the value ...
user104947's user avatar
0 votes
1 answer
2k views

Math.max returns NaN in case of null values

I am a new one in javascript and there is a case. I have a controller with many input values and I want to get the maximum value of them. I use var getMax = Math.max(field1__c,field2__c,field3__c,.....
Kostas Karagiannis's user avatar
2 votes
1 answer
1k views

How do I perform exponentiation in Apex?

I am trying to perform this calculation in apex. How do I use the exponential operator in apex? For example, the below operation: 4000*(0.01/(1-(1+0.01)^(-12)))
Prady's user avatar
  • 12.2k
2 votes
1 answer
877 views

Rebuild Excel Formula "Rate" in Apex

I am trying to rebuild the Excel formula "Rate" in APEX. This is a formula for calculating the interest percentage of a loan, based on the number of periods, payment amount and total amount. It's ...
Guy Clairbois's user avatar
0 votes
1 answer
194 views

How to calculate the following exponential logic in the trigger? [closed]

How to calculate exponential in trigger?
Sanjana's user avatar
0 votes
1 answer
180 views

Math.Round() Function returning 1E+1 when I passed 10.000 as input

I am using Math.Round() Function so when I am using I am getting output as 1E+1. My code is some Thing like this, Decimal input = 10.000; if(input != NULL){ decimal d = Math.round(input*100.0)/...
Prasad Vivek Kothalanka's user avatar
0 votes
1 answer
220 views

Doing division on a Decimal returns 0 when trying to return a percent [duplicate]

When I run the following code, it will return a 0. It should return 50.00. System.Debug((100/200)*100); I'm certain this is a simple solution. But haven't been able to find out the reason why. I ...
thinker's user avatar
  • 1,402
-6 votes
1 answer
239 views

How do I use arithmetic powers of AMPscript to finish this function? [closed]

%%[ var @abc=10 var @def=12 set @sum= /* THIS PART */ ]%%
Diego's user avatar
  • 1
0 votes
0 answers
252 views

Correct formula for the last page in pagination

I make a pagination for lightning for my list of objects. First part is great. But when i get to the last page (v.pages == v.page) - something goes wrong. Values for the number of objects are ...
MichaelLev19's user avatar
2 votes
2 answers
2k views

How can we find min of two dates in apex

I am trying to find min of two dates. I used MIN(date1,date2) but I am facing the following error: "Method does not exist or incorrect signature: void min(Date, Date)" How can we find the ...
dileep's user avatar
  • 89
0 votes
1 answer
3k views

Adding a random number generator inside a formula field in process automation

I'm automating a certain process in process automation. When the logic is correct i want a certain record to be created, so i have a field named 'Version' in this record. the 'Version' field can ...
Niveth Kumar's user avatar
3 votes
1 answer
6k views

can we use % symbol in apex controller?

When I'm using % symbol it is showing the below error message: Found punctuation symbol or operator '%' that isn't valid in Apex.
user57471's user avatar
0 votes
1 answer
138 views

Is there a way to calculate a P-Value for a T-Statistic in Salesforce?

I realized that this is outside of the Salesforce wheelhouse, but can anyone help? I have a custom class that determines the t-static from a series of pairwise tests. I have a requirement to ...
RD3's user avatar
  • 351
-1 votes
2 answers
1k views

Dynamic calculations using Apex

I need to dynamically calculate a formula in APEX, the formula will be constructed as a string. Consider something similar to JavaScript eval() function. For example I need to calculate value for ((2*...
user34950's user avatar
5 votes
1 answer
2k views

Bulkified generation of unique 6-character alphanumeric IDs, with strict validation criteria

I have a requirement to generate a unique 6-character alphanumeric ID for records on a bulkified before-insert trigger, on an object already containing about 5 million records and expected to grow to ...
Sequoyah's user avatar
  • 760
1 vote
1 answer
74 views

Mathematical function for Decimal Digits

Is there a way to get exact value for division operation like 1/24 to get exact value as 1/24 = 0.04166666666
user2703132's user avatar
1 vote
1 answer
435 views

Arithmetic expressions must use numeric arguments with aggregate results

I have object Deal__c and child object Deal_revenue__c related by the field Deal__c on on the child. I want to find the remaining amount of unbooked total by the arithemtic function described below ...
jaw999's user avatar
  • 1,308
1 vote
1 answer
316 views

Is there a modulus operator in AMPscript?

I'm looking for modulus operator in their docs but I can't find it so I though I would ask here. I have a loop written in AMPscript and I need to insert a piece of html every X item. Is there a ...
angelcool.net's user avatar
2 votes
0 answers
75 views

Adding sales tax rules for many countries

I need to add sales tax rules for a whole host of countries (around 60) as my company is about to go global selling not just in the UK. The company works with external suppliers taxed in their own ...
AdamJones's user avatar
  • 259
0 votes
1 answer
2k views

getting 3 random elements from a List

in our customer service system, when a customer phones up, the inquiries officer takes the customer through questions built out of fields populated on the customer record to check identity. Now I ...
Our Man in Bananas's user avatar
6 votes
2 answers
845 views

Possible bug in Math.round(decimal)

I have written this code and run anonymously, and got some strange results which seem to indicate a bug in Math.Round(decimal) - look like an overflow: Decimal d = 1000000000.0; Decimal dd = ...
NickJ's user avatar
  • 660
1 vote
1 answer
150 views

Remaining minutes in a day

I'm trying to get the remaining minutes of the current day, but the Datetime class its giving me headaches. (I'm going crazy) Datetime now = Datetime.now();//System.now(); System.debug(now); System....
Jose's user avatar
  • 2,102
10 votes
2 answers
8k views

aura math expressions

I'm messing with Lightning Components doing some very angular-ish things. I like that we can use two-way binding with the "updateon" tag. Here's my code: <aura:component > <aura:...
Shane McLaughlin's user avatar
4 votes
1 answer
274 views

Can we do logarithmic axes on Visualforce charts?

I'm using Visualforce Charting to display stuff in a message queue by state. But faced with a display problem: there could be 1 guy in some state and 9999 guys in any other, eg: <apex:chart data="{...
Matt and Neil's user avatar
9 votes
4 answers
3k views

How to get the floor (round down instead of up) of a number with AMPscript?

I'm doing a bit of math with AMPscript, and I'd like to be able to round a number DOWN eg: I would like 5.5, 5.6, 5.7 etc.. to become 5, not 6 The standard FormatNumber() function will automatically ...
ampersandre's user avatar
0 votes
2 answers
92 views

How to divide Oppo RSF field on Oppo Products into equal amounts based on # of Oppo Products

In opportunity line item/product we have custom field called break up fee ...which will filled if the opportunity is closed lost. In oppy we have a roll up field will calculate the sum of all break ...
user avatar
3 votes
1 answer
341 views

Do we have RADIANS math function in Salesforce?

i am trying to find nearest stores and their longitude and latitude based on customer location (lon,lat) and populate in Google map. Here is a sample query would work in MySQL. Would this same query ...
Bforce's user avatar
  • 6,786
0 votes
1 answer
2k views

Ceiling Decimal in apex

I want to get the nearest ceiling for the decimal value. For 1268.0 => I want to get 1300. For 2537.0 => I want to get 2500. It would be like Excel function. I used value.round(roundingMode....
kitokid's user avatar
  • 1,728
15 votes
3 answers
14k views

What makes a field not groupable

I'm trying to use an aggregate query, but one of the fields I want to group by is not groupable (saw it in the soql error and then verified groupable=false in the metadata). It's just a number field ...
Shane McLaughlin's user avatar
10 votes
2 answers
4k views

Comparing floating-point values

In Apex, can Decimals be compared directly. For example: dec1 > dec2 or dec1 == dec2 In other languages I sometimes run into issues with fractions such that 1/3 and 0.33 are not going to be equal. ...
Seth Stone's user avatar
11 votes
2 answers
5k views

Is there an average method for apex math

I was doing some bill calculations, and went looking in the math method for an average. Usage would be something like math.average(1, 4, 6, 7, 8, 9) math.average(ListOfIntegers) math.average(...
Shane McLaughlin's user avatar
38 votes
2 answers
91k views

Round a Decimal to two decimal places

How can I round an arbitrary Decimal to 2 decimal places (hundredths of a dollar)? My first thought was to use the Math Functions ROUND(number, numDigits): Decimal toRound = 3.14159265359; Decimal ...
Daniel Ballinger's user avatar
23 votes
9 answers
22k views

What is a concise function that formats a (String) decimal into a currency format in Apex?

goal: write the most concise function that formats a (String) decimal into a currency format in Apex. Feel free to trainwreck the code for points, I've kept mine exploded for readability purposes.
ebt's user avatar
  • 2,795