asoudek

AF Analytics - Units Of Measure (UOMs) in Equations

Blog Post created by asoudek on Aug 31, 2016

Make sure you get the correct result by using UOMs in your calculations

In some situations, the expressions will contain calculations that are dependent on a specific unit of measure for each Attribute used in the calculation.  We may also want to make sure that if the
output of the expression is in a certain unit of measure, and we map it to an Attribute, that it will be independent of the Attribute’s default unit of measure setting.  For example, let’s say we have an expression result in lb and it is mapped to an Attribute whose Default UOM setting is also lb.  Then later, we change the Attribute’s Default UOM setting to kg, but the expression result is still in lb and it will not be converted to kg unless you do what is in the example below.

 

In this example, I want to calculate the mass from the Volume and Density Attributes and assign it to the Mass Attribute.  To make this bullet proof so that I do not get any surprises in the future I make sure that the units of measure for Volume and Density are in the units that will give me the resulting mass in lb.

k1.jpg

When I look at the result of the analytic in the Element all is good.

k2.jpg

Sometime later, someone has changed the default unit of measure for the Mass Attribute from lb to kg.  I now get the wrong answer.  This is a bit of a sticky wicket as the English say.

k3.jpg

If I was smarter when I first created the Analysis this would not have been a problem.  If you put in the following additional Variable in the expression and map that to the Mass Attribute, then all will be correct.

k4.jpg

The Element now show the correct value, all is well.

k5.jpg

(Note: KB01366 knowledge based article gives more details on UOM behavior in expressions)

Outcomes