The Assette Data Object Editor supports a variety of expressions and functions that allow you to manipulate and calculate data effectively. One of the fundamental mathematical operations available is the “ADD” expression, which is performed using the +
operator.
Mathematical Operators Overview #
Before exploring the “ADD” expression in detail, let’s review the basic mathematical operators supported by the Data Object Editor:
- Addition (
+
): Adds two or more numbers together.- Example:
1 + 2 + 3
returns6
.
- Example:
- Subtraction (
-
): Subtracts one number from another.- Example:
10 - 9 - 8
returns-7
.
- Example:
- Multiplication (
*
): Multiplies two or more numbers.- Example:
1 * 2 * 3
returns6
.
- Example:
- Division (
/
): Divides one number by another.- Example:
1000 / 10 / 10
returns10
.
- Example:
The “ADD” Expression Using the “+” Operator #
In the Assette Data Object Editor, addition is performed using the + operator. This operator allows you to add numerical values together to calculate sums.
Syntax #
value1, value2, value3: Numeric values or variables you wish to add together.
value1 + value2 + value3 + …
Examples #
Simple Addition
Add two numbers. Result: 15
5 + 10
Adding Multiple Numbers
Add several numbers in a sequence. Result: 20
2 + 4 + 6 + 8
Using Variables
If you have variables representing data points, you can add them directly. Result: Sum of the revenues for all four quarters.
revenueQ1 + revenueQ2 + revenueQ3 + revenueQ4
Combining with Other Operators
You can combine addition with other mathematical operations. Result: Total cost including shipping.
(price * quantity) + shippingCost
Grouping with Parentheses #
Use parentheses ( and ) to group expressions and control the order of operations.
Example
Calculate the total cost with a discount:
(totalPrice - discount) + tax
Without Parentheses
This subtracts discount from totalPrice and then adds tax.
totalPrice - discount + tax
With Parentheses
This adds discount and tax first, then subtracts the result from totalPrice.
totalPrice - (discount + tax)
Important Considerations #
- Order of Operations: The Data Object Editor follows standard mathematical order of operations (PEMDAS/BODMAS). Operations inside parentheses are evaluated first, followed by multiplication and division, then addition and subtraction.
- Data Types: Ensure that the values you are adding are numerical. Adding non-numeric data may result in errors or unintended results.
- Null and Undefined Values:
- Null: Represents a null value (e.g., data point not available).
- Undefined: Represents an undefined or unassigned value (e.g., result of dividing by zero).
Use the HasValue function to check if a value is neither null nor undefined before performing addition:
HasValue(value1) and HasValue(value2) ? (value1 + value2) : defaultValue
Conditional Addition:
You can use conditional expressions to add values only if certain conditions are met.
(quantity > 0) ? (price * quantity) : 0
This calculates the total cost only if quantity is greater than 0.
Using the Mod and Power Functions
In addition to the + operator, the Data Object Editor provides mathematical functions that can be used in conjunction with addition:
- Mod(n1, n2): Returns the remainder of n1 divided by n2.
- Example: Mod(11, 3) returns 2.
- Power(n1, n2): Calculates n1 raised to the power of n2.
- Example: Power(10, 3) returns 1000.
- These functions can be combined with addition for more complex calculations.
Example
Calculate the sum of a number and its square. If number is 5, the expression evaluates to 5 + 25 = 30.
number + Power(number, 2)
Practical Use Cases #
Calculating Totals.
Compute the total sales amount:
unitPrice * quantitySold
Aggregating Data
Add up different expense categories to get the total expenses:
travelExpenses + lodgingExpenses + mealExpenses
Adjusting Values
Increase a value by a certain percentage:
value + (value * percentageIncrease / 100)
Calculating Averages
Compute the average of several numbers.
(score1 + score2 + score3) / 3
Summary #
- The “ADD” expression in the Assette Data Object Editor is performed using the + operator.
- Use the + operator to add numerical values or variables.
- Combine addition with other mathematical operations for complex calculations.
- Use parentheses to control the order of operations.
- Ensure values are numeric and handle null or undefined values appropriately.