# Questions tagged [math]

The tag has no usage guidance.

30 questions
Filter by
Sorted by
Tagged with
76 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)))
115 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 ...
26 views

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

How to calculate exponential in trigger?
31 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)/...
19 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 ...
76 views

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

%%[ var @abc=10 var @def=12 set @sum= /* THIS PART */ ]%%
57 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 ...
1k 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 ...
630 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.
81 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 ...
539 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*...
769 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 ...
38 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
262 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 ...
249 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 ...
67 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 ...
1k 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 ...
659 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 = ...
64 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....
6k 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:...
244 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="{...
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 ...
84 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 ...
236 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 ...
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....
9k 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 ...
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. ...
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(...