#
Where to use Spectre Functions

When working with Spectre files, you can use certain categories of functions in all the file types: *build*, *cplan*, *dive*, *measures*, and *qvset*. These categories include Conversion Functions, Date and Time Functions, Logic Functions, Math Functions, and String Functions.

You cannot determine where other functions work by file type aloneâ€”instead, examine the *context *within the expression. For instance, you can use ``value("X")`` whenever the context involves only one record. If there are multiple records, you need to use ``sum(value("X"))`` or ``info(value("X"))``, or another Summary function that processes rows of data to return one result.

Most Summary functions are meant to be used on multiple records to produce a single value. The expression argument they take runs on one row at a time. So the ``value()`` function, which only works on one row, can be used inside those Summary functions. Use this technique with the following Summary functions: any, average, first, geomean, harmean, info, kahan_sum, kurtosis, last, max, median, min, mul, skewness, stddev, and sum.

On the other hand, functions such as ``top()`` or ``parent()`` take an argument that is meant to be run on multiple records, so ``value()`` does not work. Other functions that require summary expressions are the Dimension Functions, except dimcount, filter, rank, squash, and squash_right.

See also: About Spectre Expressions.