Questions tagged [math]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-6
votes
1answer
40 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
35 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
374 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 ...
1
vote
1answer
309 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.
-1
votes
1answer
77 views

Get all possible combinations of child records

I have a Parent Object let's call it X__c and I have 4 child objects Ax__c, Bc__c, Cc__c, Dc__c I'm trying to create a List of Wrapper class out of the following data structure: The above data ...
0
votes
1answer
68 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
276 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
399 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
35 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
193 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
206 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
56 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
992 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
623 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
53 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
5k 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
222 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="{...
8
votes
4answers
1k 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
77 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
202 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
2answers
8k 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
2k 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(...
28
votes
2answers
40k 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; ...
21
votes
8answers
19k 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.