The Assette Data Object Editor provides a range of expressions and functions that enable you to manipulate and calculate data effectively. One of the fundamental mathematical operations available is the “Minus” expression, which is performed using the “-"
operator.
Mathematical Operators Overview #
Before exploring the “Minus” expression in detail, it’s helpful to 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 “Minus” Expression Using the -
Operator #
In the Assette Data Object Editor, subtraction is performed using the -
operator. This operator allows you to subtract numerical values from each other to calculate differences.
value1, value2, value3: Numeric values or variables you wish to subtract in sequence.
value1 - value2 - value3 - ...
How It Works #
- Left-to-Right Evaluation: Subtraction is performed from left to right.
- Negative Results: If the result of the subtraction is less than zero, the result will be a negative number.
Examples
Simple Subtraction
Subtract one number from another. Result: 10
15 - 5
Subtracting Multiple Numbers
Subtract several numbers in sequence. Result: 10
20 - 5 - 3 - 2
Using Variables
If you have variables representing data points, you can subtract them directly
totalRevenue - totalExpenses
Combining with Other Operators
You can combine subtraction with other mathematical operations. Result: Total cost after discount for a given quantity.
(price - discount) * quantity
Grouping with Parentheses
Use parentheses "("
and “)"
to group expressions and control the order of operations.
For example, calculate the remaining budget:
initialBudget - (expensesTravel + expensesLodging + expensesMeals)
Without Parentheses:
This would incorrectly add expensesLodging
and expensesMeals
to the result of initialBudget - expensesTravel
.
initialBudget - expensesTravel + expensesLodging + expensesMeals
Order of Operations:
The Data Object Editor follows standard mathematical order of operations. Operations inside parentheses are evaluated first, followed by multiplication and division, then addition and subtraction.
value1, value2, value3
value1 - (value2 - value3) * value4 + value5
Negative Numbers:
If the subtracted value is larger than the initial value, the result will be negative. Result: -5
5 - 10
Data Types #
Ensure that the values you are subtracting are numerical. Subtracting non-numeric data may result in errors.
Null and Undefined Values:
- Null: Represents a null value (e.g., data point not available).
- Undefined: Represents an undefined or unassigned value.
Use the HasValue
function to check if a value is neither null
nor undefined
before performing subtraction:
HasValue(value1) and HasValue(value2) ? (value1 - value2) : defaultValue
Using Subtraction in Expressions #
You can use the subtraction operator in various expressions to perform calculations relevant to your data.
Calculating Differences
Difference Between Two Dates
Calculate the number of days between two dates. Note for a more accurate calculation, consider using date difference functions if available.
Day(endDate) - Day(startDate)
Variance Analysis
Determine the variance between actual and budgeted amounts: Result: Positive result indicates over budget, negative result indicates under budget.
actualAmount - budgetedAmount
Percentage Change
Calculate the percentage decrease. Result: Percentage of the discount.
((originalPrice - salePrice) / originalPrice) * 100
Practical Use Cases #
Financial Calculations
Compute net profit:
totalRevenue - totalExpenses
Date Manipulation
Determine the remaining time for a task:
totalDuration - timeElapsed
Data Analysis
Find the deviation from an average:
dataPoint - averageValue