# Calculation code to build custom formulas

The following page describes the syntax you can apply when you want to build custom formulas in your report tables. You find the custom formula section here:

## Multiline custom formula

If you want to create a multi line script, please use the return command in the start and ; in the end:

``````return (CellValue("Row1","Ginger_1_Average_f2bf-21db").Value
+ CellValue("Row2","Ginger_1_Average_f2bf-21db").Value
+ CellValue("Row3","Ginger_1_Average_f2bf-21db").Value
+ CellValue("Row4","Ginger_1_Average_f2bf-21db").Value
+ CellValue("Row5","Ginger_1_Average_f2bf-21db").Value) / 5;``````

## Switching values

The same syntax applies to rows. Use CurrentRowName instead and prepare cases with the different row names.

``````switch(CurrentColumnName)
{
case "Column2": return 2314 * 12;
case "Column3": return 2313 * 12;
case "Column4": return 2294 * 12;
}
return 0;``````

## If condition in custom formula

The example is taken from a table where negative differences should be exchanged with the value 0.

``````var result = (double)CellValue("Row4",null).Value - (double)CellValue("Row6",null).Value;
if (result < 0) {result=0;};
return result;``````

## Round Values

In the following script the term is rounded to an number without decimal

``Math.Round(((double)CellValue("Row2","Column1").Value/(double)CellValue("Row1","Column1").Value*100),0)``

The full scope of the script editor is described in the dotnet language reference:

Updated on April 17, 2023