# Questions tagged [math]

The tag has no usage guidance.

36 questions
Filter by
Sorted by
Tagged with
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 ...
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 ...
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'...
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 ...
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,.....
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)))
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 ...
194 views

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

How to calculate exponential in trigger?
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)/...
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 ...
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 */ ]%%
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 ...
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 ...
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 ...
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.
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 ...
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*...
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 ...
1 vote
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
1 vote
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 ...
1 vote
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 ...
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 ...
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 ...
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 = ...
1 vote
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....
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:...
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="{...
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 ...
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 ... 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 ...
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....
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 ...
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. ...
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(...