Client Expression Functions and Operators

This appendix provides reference information for the operators and functions that are allowed in client expressions.

This chapter covers the following topics:

About This Reference

This appendix provides reference information for the operators and functions that are allowed in client expressions.

Operators in Client Expressions

You can use the following operators in a client expression:

Precedence of calculations follows standard algebraic rules.

Finally, to specify a series, use either of the following syntaxes:

For example: Sales [ -1] refers to the previous period(column). Sales [ 1] refers to the next period (column). [0] is not allowed.

Abs Function

Returns the absolute value of a number.

Syntax

The value of argument must be either numeric or null.

Case

Tests the values of a series or expression and returns values based on the results of the test. If more than one WHEN clause matches the given input, the function returns the result corresponding to the first matching one.

Syntax

The square brackets indicate optional parts of the syntax. The arguments are as follows:

Examples

The following expressions are valid uses of Case:

See also

CurrentRow

Returns the number of the worksheet row that currently has the focus, that is, the worksheet row that the user has selected.

This function is easiest to use in color expressions.

Within the main client expression for a series, you can use this function to find the relative position of a row, in relation to another row. For example, you can use it indirectly to find the last row number.

Note: Remember that apart from the color expression and the edit-lock expression, the worksheet does not reevaluate client expressions until a value changes in the worksheet. That is, the action of moving the cursor does not force the main client expressions to be reevaluated.

Note: This means that if you use this function within the main client expression for a series, the expression should also refer to a series that the user will change.

If the function fails, it returns 0.

Syntax

Notes

When used in a general client expression (that is, neither a color expression nor an edit-lock expression), this function always returns 1.

When used in a color or edit-lock expression, this function returns the number that corresponds to the row that currently has the focus, that is, the row that the user has currently highlighted.

You can use this function in an edit-lock expression, but the GetRow function is a better choice. For example, consider the following possible edit-lock expressions:

Both expressions make it impossible to edit the series for the rows before the start of the forecast. However, if you use the former expression, all the cells will appear editable if the user selects a row before the start of the forecast, which would be very confusing.

See also

Date

Given a string argument, returns a date. This function works only in the desktop.

Syntax

See also

Day

Returns an integer indicating the day of the month of the given date value.

Syntax

The value of argument must be either a date or null.

Exp

Returns the number e raised to the specified power.

Syntax

The value of argument must be either numeric or null.

Example

This expression returns 7.38905609893065:

These statements convert a natural logarithm (base e) back to a regular number. When executed, Exp sets value to 200:

ForecastFirstRow

Returns the number of the row in the current worksheet where the forecast begins. It refers to the batch forecast.

Syntax

See also

Fpos

Periods of supply. Checks the period of the first arguments against the period (from the next period) of the second argument. This function works only on the forecast data.

Note: You cannot use this function in color expressions.

Syntax

Each argument should be a series.

Examples

The section that uses “GetRow() >= ForecastFirstRow()” is essential because the expression works only in forecast.

Date Inventory (SupplyTinv) Forecast (SupplyTinvFinalFcst) Third Series with FPOS
January 12 5 2.5
February   5  
March   4  
April   6  

Fpos = 5 + 4 + 6*0.5 = 2.5. The inventory (12) will cover the forecast for 2.5 periods.

Fsum

Returns a series that adds multiple future consecutive items from a given series. The second argument, either a number or another series, specifies the number of time periods to use for each sum.

Note: You cannot use this function in color expressions.

Syntax

The arguments are as follows:

The parameters can be only the names of data series or actual values. It is not permitted to enter other functions or [ ] brackets inside the FSUM function.

Examples

GetRow

Returns the number of the worksheet row. You generally use this function in edit-lock expressions that lock worksheet rows depending on position.

If the function fails, it returns 0.

Syntax

See also

GetWorksheetLevelNumber

Returns an integer that indicates the relative level of the summary row where this function is used.

Note: This function is available only for use within the summary row of a series.

Syntax

You use this function to achieve different kinds of summaries for a series in different contexts in a given worksheet. Specifically, when a worksheet uses one or more levels on the x-axis, the worksheet table includes intermediate summary rows, for example:

the picture is described in the document text

By default, the final summary row and all the intermediate summary rows are calculated in exactly the same way. The GetWorksheetLevelNumber function provides a way to distinguish each summary row, so that you can create a different summary functions as needed, at each of those levels.

To determine the relative aggregation level of the summary rows, the function considers the layout of the worksheet. The following figure relates the summary levels to the x-axis layout:

the picture is described in the document text

For level 1 in the worksheet, GetWorksheetLevelNumber returns 1, and so on. If there are n levels on the x-axis of the worksheet, the function returns n+1 for the final summary.

Example

Suppose that you want to display only the intermediate summary but not the final summary, as follows:

the picture is described in the document text

To achieve this, you could use a summary row expression of the following form:

If

Tests a true/false expression and returns one of two possible values based on the results of the test.

Syntax

Examples

This expression returns 7 if Retail_history is greater than Retail_model; otherwise it returns Demand:

See also

Is_Modified

Returns true or false depending on whether a given series has been edited since the last time data was saved.

Syntax

Here series should be an editable series. The function does not detect whether a calculated series has been changed by having its inputs edited.

Examples

The following expression returns the Inventory series if Pseudo has been modified and returns the Safety series if Pseudo has not been modified:

IsNull

Returns true or false depending on whether a given series equals null.

Syntax

Mod

Returns the remainder (modulus) of a division operation.

Note: The results of this function take slightly longer to display than for other functions.

Syntax

The value of argument1 and argument2 must be either numeric or null.

Examples

Month

Returns an integer indicating the month of the given date value.

This can be used to show or use dates in calculations. Also, a planning process can be maintained, while the locking expression is based dynamically on dates. For example, override is allowed only in the first two weeks of the month.

Syntax

The value of argument must be either a date or null.

Pi

Returns the number pi multiplied by a specified number.

Syntax

The value of argument must be either numeric or null.

The function returns -1 if an error occurs.

Examples

You can use this function to convert angles to and from radians. For example, because pi equals 180 degrees, you can convert 60 degrees to radians as follows:

Rand

Returns a random integer between 1 and a specified upper limit.

Note: This function does not generate true random numbers. If you repeatedly call this function, you will receive a pseudo random sequence.

Syntax

Examples

The following expression returns a random whole number between 1 and 10:

Round

Returns a number rounded to a specified number of decimal places.

Syntax

Examples

The following expression returns 9.62:

The following expression returns 9.63:

The following expression returns 9.600:

The following expression returns -9.63:

see also

RowCount

Returns the numbers of rows in the worksheet where this function is used.

Syntax

See also

Sqrt

Returns the square root of a non negative number.

Syntax

The value of argument must be either a non negative number or null.

Examples

This expression returns 1.414213562373095.

This expression results in an error at execution time.

SummaryAVG

Returns the average value of the displayed rows of the specified series.

Note: This function is available only for the summary row of a series.

Syntax

Here argument is the name of a series that has a numeric value.

Any null value is treated as zero.

SummaryCount

Returns the total count of the displayed rows of the specified series.

Note: This function is available only for the summary row of a series.

Syntax

Here argument is the name of a series that has a numeric value.

SummaryMax

Returns the maximum value of the displayed rows of the specified series.

Note: This function is available only for the summary row of a series.

Syntax

Here argument is the name of a series that has a numeric value.

Any null value is treated as zero.

SummaryMin

Returns the minimum value of the displayed rows of the specified series.

Note: This function is available only for the summary row of a series.

Syntax

Here argument is the name of a series that has a numeric value.

Any null value is treated as zero.

SummarySum

Returns the sum of the displayed rows of the specified series.

Note: This function is available only for the summary row of a series.

Syntax

Here argument is the name of a series that has a numeric value.

Any null value is treated as zero.

SummaryWAVG

Returns the weighted average of the displayed rows.

Note: This function is available only for the summary row of a series.

Syntax

Here argument1 and argument2 are the name of series that have a numeric value. Tis function performs a weighted average of the values in argument1, using the values in argument2 as the weights.

Any null value is treated as zero.

Today

Returns the current system date.

This can be used to show or use dates in calculations. Also a planning process can be maintained, while the locking expression is based dynamically on dates. For example, override is allowed only in the first two weeks of the month, and so on.

Syntax

Truncate

Returns a number truncated to a specified number of decimal places.

Syntax

The value of argument1 and argument2 must be either numeric or null. If numeric, argument2 should be a non negative integer between 0 to 18, inclusive.

Examples

The following expression returns 9.2:

The following expression returns -9.2:

See also

Year

Returns a four-digit integer indicating the year of the given date value.

This can be used to show or use dates in calculations. Also a planning process can be maintained, while the locking expression is based dynamically on dates. For example, override is allowed only in the first two weeks of the month, and so on.

Syntax

The value of argument must be either a date or null.

Demantra handles years from 1000 to 3000 inclusive. If your data includes date before 1950, such as birth dates, always specify a four-digit year so that Year and other functions, such as Sort, interpret the date as intended.

Z_Val

Z_val is used in safety stock calculation. Given a specified service level, this function returns a value to use in the safety stock calculation, by looking up values in a table.

Syntax

The value of argument must be either numeric or null.

Z_Val Table

If the argument is... The function returns this z_val...
greater than the min_level and less than or equal to the max_level
0 0.85 1.04
0.85 0.86 1.09
0.86 0.87 1.13
0.87 0.88 1.18
0.88 0.89 1.23
0.89 0.9 1.282
0.9 0.91 1.34
0.91 0.92 1.41
0.92 0.93 1.48
0.93 0.94 1.56
0.94 0.95 1.645
0.95 0.96 1.75
0.96 0.97 1.88
0.97 0.98 2.06
0.98 0.99 2.33
0.99 0.995 2.576
0.995 0.999 3.09
0.999 0.9995 3.291
0.9995 0.99995 3.891
0.99995 0.999995 4.417

Example

If we select a service level of 95.5% then the expression will look at the table at the following line, because this lies between 0.95 and 0.96 (the minimum and maximum values in the range). A z_val value of 1.75 is returned.

min_level max_level z_val
0.95 0.96 1.75