Questions tagged [math]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
23 views

Conditional Math Equation in Report

I have a Report that includes a calculation for "days overdue" of a Case (Due Date - Closed Date). SFDC is calling this field CDF1. I want to add a calculation for the average days overdue ...
0
votes
1answer
259 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,.....
2
votes
1answer
211 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)))
2
votes
1answer
338 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 ...
0
votes
1answer
63 views

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

How to calculate exponential in trigger?
0
votes
1answer
40 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)/...
0
votes
1answer
42 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 ...
-6
votes
1answer
104 views

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

%%[ var @abc=10 var @def=12 set @sum= /* THIS PART */ ]%%
0
votes
0answers
118 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 ...
0
votes
1answer
2k 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 ...
2
votes
1answer
1k 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.
0
votes
1answer
100 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 ...
-1
votes
1answer
733 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*...
5
votes
1answer
1k 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 ...
1
vote
1answer
40 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
1
vote
1answer
357 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 ...
1
vote
1answer
259 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 ...
2
votes
0answers
69 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 ...
0
votes
1answer
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 ...
6
votes
2answers
710 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 = ...
1
vote
1answer
67 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....
10
votes
2answers
7k 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:...
4
votes
1answer
257 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="{...
9
votes
4answers
2k 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 ...
0
votes
2answers
85 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 ...
3
votes
1answer
258 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 ...
0
votes
1answer
1k 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....
10
votes
3answers
10k 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 ...
10
votes
2answers
3k 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. ...
11
votes
2answers
3k 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(...
35
votes
2answers
63k 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 ...
22
votes
9answers
20k 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.