What Is A "User Defined Function"?

When a calculation, or part thereof, is repeated a few times, it is advisable to rather build a user defined function and call it instead as this allows for easier maintenance of the calculation.

The function “Definition” is a standard Microsoft.NET C# static method and must have a return value.

For example, if you find yourself building a lot of measures that do standard efficiency calculations, you can replace the calculation with a function that is defined as follows:


To create a user defined function, right-click on the User Defined folder under Functions in the Toolbox Tab, select New > Function


Give your function the name by which it will be called in your calculation, e.g. Efficiency.  Double-click the Efficiency function that is created.

Complete the C# expression, making sure that you're happy with the parameters that you're passing in to the function, and the value that you are returning.  When you're done, click on the green "validate" check button in the top right corner of the function expression editor.  If there are no errors detected, the green check will turn gray.  

public static double? Efficiency(double? Actual, double? Rating)
// Standard Efficiency Calculation
return Actual / Rating * 100.0;

Now you can use your function in a calculated measure, as shown in the following image.



Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request