0

Using the ValueTransform Property (version 21)

The 'ValueTransform' property of a control can be used to convert the current tag value using an expression. The keyword, value, is used as placeholder for the actual value within the expression. For example...

  • value*10
  • Truncate(value)
  • Pow(value,3)

Calculations are performed using the C# NCalc library. Below are the available operators and functions.

Operators

Logical Operators

or, ||, and, &&

Relational Operators

=, ==, !=, <>, <, <=, >, >=

Math Operators

+, -, *, /, %

Bitwise Operators

& (and), | (or), ^ (xor), << (left shift), >> (right shift)

Unary Operators

!, not, -, ~ (bitwise not)

Functions

Name

Description

Usage

Result

Abs

Returns the absolute value of a specified number.

Abs(-1)

1

Acos

Returns the angle whose cosine is the specified number.

Acos(1)

0

Asin

Returns the angle whose sine is the specified number.

Asin(0)

0

Atan

Returns the angle whose tangent is the specified number.

Atan(0)

0

Ceiling

Returns the smallest integer greater than or equal to the specified number.

Ceiling(1.5)

2

Cos

Returns the cosine of the specified angle.

Cos(0)

1

Exp

Returns e raised to the specified power.

Exp(0)

1

Floor

Returns the largest integer less than or equal to the specified number.

Floor(1.5)

1

IEEERemainder

Returns the remainder resulting from the division of a specified number by another specified number.

IEEERemainder(3, 2)

-1

if

Returns a value based on a condition.

if(3 % 2 = 1, 'value is true', 'value is false')

'value is true'

in

Returns whether an element is in a set of values.

in(1 + 1, 1, 2, 3)

TRUE

Log

Returns the logarithm of a specified number.

Log(1, 10)

0

Log10

Returns the base 10 logarithm of a specified number.

Log10(1)

0

Max

Returns the larger of two specified numbers.

Max(1, 2)

2

Min

Returns the smaller of two numbers.

Min(1, 2)

1

Pow

Returns a specified number raised to the specified power.

Pow(3, 2)

9

Round

Rounds a value to the nearest integer or specified number of decimal places.

Round(3.222, 2)

3.22

Sign

Returns a value indicating the sign of a number.

Sign(-10)

-1

Sin

Returns the sine of the specified angle.

Sin(0)

0

Sqrt

Returns the square root of a specified number.

Sqrt(4)

2

Tan

Returns the tangent of the specified angle.

Tan(0)

0

Truncate

Calculates the integral part of a number.

Truncate(1.7)

1

4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • igorsantos
    • igorsantos
    • 3 mths ago
    • Reported - view

    How do I add different values from ValueBox?
    For example: I have three different value boxes and I need the sum of all these three in a new valuebox.
    If not possible, how can I have the sum of three different tags?

    (version 21)

    Thank you.

    Like
    • igorsantos it's quite simple. I think V21 already has this available: when you drag and drop a ValueBox Control, you can choose whether to choose a tag or build a calculation. By choosing the latter, you'll be able to build the sum of the tags the way you desire. The catch is that you need first to instantiate the tags inside thier own ValueBox, in order for the calculation to be able to "see" them and let you choose. I do this on my dashboards to make sums, means, and the trick is to instantiate the tags you desire, but if you don't need to show them, just make them tiny and invisible and put them in a separate corner.

       

      You could achieve the same without creating ValueBoxes for every tag you'll need in your calculation by using the scripting engine, but that would be harder.

      Like
      • igorsantos
      • igorsantos
      • 3 mths ago
      • Reported - view

      Hi matheus. zanetti , thank you.

       

      When i drag and drop a ValueBox Control, it does not give me the option to build a calculation though. It only allows me to add a new tag. 
      Is there a way to build a calculation in the "ValueTransform" option in the Properties option?

      Like
    • igorsantos 

      This functionality, the ability to create a calculation in a control, became available in v22.2. Here is an article explaining that functionality: https://helpcenter.canarylabs.com/t/q6hvllp/how-to-build-ad-hoc-calculations-version-23. If you have an active Customer Care agreement with us, you can request the latest version to upgrade. As of right now, the current release is 23.2.

      Like