Extensions and Simplifications for Calculated Custom Fields

3 years ago

Extensions and Simplifications for Calculated Custom Fields

We’ve made a few extensions to Calculated Custom Fields with some of our recent releases (3.8.9 and 3.9.0). We also simplified the formulas required for Boolean expressions and calculations with potentially null values. I’ve defined these terms below in case you’re not sure what they are.

Calculated Custom Fields: Used to create your own metrics for custom fields in Targetprocess.

Null value: A value which is unknown, e.g. hours of effort remaining for a project which has not been started. Please note that null does not equal zero; it’s simply an unknown variable. A nullable expression is any calculation with a potentially null result.

Boolean expression: This is basically just a true / false statement. If a field generates a yes or no answer, it’s probably using a Boolean expression.

 

Nullable Expressions:

We’ve extended Calculated Custom Fields to work much better with nullable expressions by adding an IFNONE operator.  This has simplified the formulas needed for such calculations by removing some of the developer terms which were formerly required, such as ternary operators.

So, when you need a default value for a nullable expressions. You can use IFNONE(a,0) instead of a.HasValue ? a.Value : 0

Old: Bugs.SUM(TimeSpent).HasValue ? Bugs.SUM(TimeSpent).Value : 0

New: IFNONE(Bugs.SUM(TimeSpent), 0).

 

Boolean Expressions

Decimal values are now automatically converted to double (nullable double) values in case a double value and a decimal value must be used in one expression. Basically, this means you don’t have to use the phrase Convert.ToDouble(it.Decimal) when working with decimal values. This also works for IFNONE/IIF operators: you can simply write IFNONE(it.NullableDouble, it.NullableDecimal) or IIF(it.NullableDecimal.HasValue, it.NullableDecimal.Value, it.Double).

Old: Convert.ToDouble(TotalPoints.HasValue?TotalPoints.Value:0) / (EndDate-StartDate).TotalDays

New: TotalPoints.HasValue?TotalPoints.Value:0 / (EndDate-StartDate).TotalDays

 

Nullable Bool:

Nullable bool is now automatically converted to bool (with “false” used for null values). So, if nullable bool is used in a place where bool should be used, it will be converted from it.NullableBool to it.NullableBool == True.

Old: IIF(EntityState.IsFinal == True,0,Effort)

New: IIF(EntityState.IsFinal,0,Effort).

If you have any questions about these changes, please feel free to ask us in the comments section below or contact our support team. Have a good day! 

You can subscribe to our monthly newsletter here:

Thank you!

Сheck out latest blog posts:

Get started for free

Manage complex work, projects and products with Targetprocess

Enter your email
By clicking "Continue", you acknowledge and agree that we will process your personal data in accordance with our Service Privacy Policy and Terms of Service.

We’ve sent you a confirmation e-mail — please, go check it.

Live demo

With our product specialist Ksenia