This article provides code snippets for common expressions which can be copied, adapted and pasted to populate properties with expressions. Typically, the required adaptation is to replace illustrative property keys with the keys for your required properties. The elements of each snippet which require adaptation are highlighted:
copy.everything.including.symbols.and.spaces.
("insertYourPropertyKey+insertYourPropertyKey")
Note:
- Property Keys need to be entered accurately, taking account of character case and spaces.
- Template analysis packs and the Organization Modelling Guided Experience contain pre-built, configurable expressions. These solutions are recommended starting points for analysis and modelling.
- In addition to your dataset properties, Orgvue Generated Properties can be used in expressions.
- The Gizmo Cookbook is available users wanting to gain Jedi-level expression writing status.
Adding cost components to calculate total compensation
node.math("currentSalary+currentBonus")
Subtracting cost values to calculate variance from budget
node.math("actualSalary-budgetSalary")
Calculating a percentage (e.g. bonus as a percentage of salary)
node.math(
"currentBonus/currentSalary*100")
Projecting a percentage cost increase
node.math("
salary*
1.05")
Applying currency conversion to costs
When exchange rate values are included in a property:
node.math("actualSalary*currencyExchangeRate")
Or applying a specific multiplier:
node.math("actualSalary*0.75")
Flagging people/ positions when a threshold is exceeded
Example 1: Flagging people/ positions based on cost thresholds
This expression returns a specified value (e.g., "Requires central team approval") when a threshold (e.g., 100,000) is exceeded for a given property (e.g., "Planned Compensation"). When the threshold is not exceeded, an alternative value is returned (e.g., "Within local approval limits").
node.plannedComp.case(is.gtEq(100000), "Requires central team approval", "Within local approval limits")
Example 2: Flagging people/ positions beyond a target number of layers
This example uses a generated property (depth) there is therefore no need to adapt the property key. The threshold number of organizational layers and the values to be applied to cases within and beyond the threshold should be adapted.
node.depth.case(is.gt(7), "Outside Depth Guideline", "Within Depth Guideline")
Categorizing people/ positions according to thresholds
This expression returns specified values (e.g. "Low", "Medium", and "High") according to defined thresholds (e.g., less than 40,000; 40,000-80,000 and greater than 80,000) for a given property (e.g. "Position Cost").
node.
positionCost.case(is.lt(40000),
"Low
", is.lt(80000),
"Medium
", is.gtEq(80000),
"High
")
Calculating employee age
For returned values to include decimal places:
node.dateofbirth.
age()
For returned values to be expressed in whole years:
node.dateofbirth.
age().floor()
Tip: The expression provided for “Categorizing people/positions according to thresholds” (above) can be adapted to populate an ‘Age Group’ property.
Calculating tenure
node.startdate.
age()
Note: In expressions, ‘age’ is used to find the difference between a past date and today’s date. ‘Age’ is not limited to the age of a person.
Tip: The expression provided for “Categorizing people/positions according to thresholds” (above) can be adapted to populate a ‘Tenure Group’ property.
Expressing durations in days, weeks or months
The above examples express employee age and tenure in years.
Values can also be expressed in days (‘d’), weeks (‘w’) or months (‘m’). Taking the example of tenure:
node.startdate.
age('d')
node.startdate.
age('w')
node.startdate.
age('m')
Calculating the difference between two date properties
For example, to calculate the age of an employee when they joined the organization:
node.
startdate.dateDiff(node.dateofbirth,
'y').floor()
Combining text properties
For example, to combining name first name and family name properties to express full name:
node.forma
t(
"{firstName} {familyName}")
Grouping direct reports to summarize teams
The illustration below shows the result when the expression is used to populate a property named “Direct reports”.
node.ac.groupby('positionTitle').format("{values.count} {key}").join('\n')
A team summary can also be produced using an employee name property.
Populate properties with manager property values
The illustration below shows the result when the expression is used to populate three properties when new positions are created.
The expression returns the manager's value for a specified property. A separate article provides a step-by-step guide for manager property values to be applied as default, editable values when positions are created.
node.parent.
propertyKey
Comments
0 comments
Please sign in to leave a comment.