Spreadsheet Formulas - Case States Functions

Statistica provides a predefined broad selection of case-state functions that can be used in spreadsheet formulas like all other functions.

Below is a list of all available case-state spreadsheet functions (parameters are given in parentheses).
  

AsCaseState(number) Converts its numeric argument into a 32 bit case state value.

Case states are stored internally as 32 bit integers in the following format, where bit positions are number from 1 (the least significant bit) to 32:

Bit 1 2 3 4 5
Value 1 2 4 8 16
Flag Label Hidden Excluded Selected Marked

Bits 6 through 13 form an 8 bit index (one based) into an internal color palette, with 0 meaning no color.

Bits 14 through 19 are a 6 bit value that corresponds to a value of enum PlotMarkerType, in the Statistica type library. The value stored in these bits is (PlotMarkerTypeValue+1), with 0 meaning no marker assigned.

For example:

=AsCaseState(1+4)returns a case state value with Label and Excluded turned on.

BVal(rgb_val) Extracts and returns the blue value from an RGB color value.
CaseState Returns the case state value for the current case.
Note: This can be used, among other things, to write conditional expressions based on current case states. For example, EXCLUDED(CASESTATE) will return a nonzero value (true) if the current case is marked excluded.
ColorOf(casestate_value) Returns the index of the color in the case state value argument. For example:

=ColorOf(ColorState(V0))

returns V0 (modulo 65)

ColorOfRGB(casestate_value) Returns the color as RGB integer value in the case state value argument.
ColorState(n) Returns a case state value with the color set to the nth color, modulo 65. The argument is an index into the color palette that displays in the case state color combo box on the spreadsheet toolbar. There are 65 such colors, and the indexing starts from 0. If the argument is larger than 65 the index is computed modulo 65. A negative argument wraps around, so that -1 is color number 65. Thus the spreadsheet formula. For example:

=ColorState(v0-1)

This will return case states with colors that cycle through the palette and repeat every 65 cases.

ColorStateRGB(rgb_val) Returns a case state value with the color set to the specified RGB value. See RGB function. For example:

=ColorStateRGB(RGB(255,0,0))

This will return case state with color set to red.

CombineStates(casestateval1, casestateval2, ..., casestatevaln) Combines the case state arguments into one case state value. this function shall accept any number of arguments, each of which must be a case state value, and combines them into one case state.

Boolean type states such as Labeled, Hidden, Excluded, etc, are OR'ed so that if any of the arguments has Hidden set, for example, this result will also have Hidden set:

=CombineStates( ExcludedState(modulo(v0,2)=0), HiddenState(modulo(v0,3)=0) )

Excluded(casestate_val) Returns true if the case state value argument has the excluded flag set.
ExcludedState(x) Returns a case state value with the Excluded flag set if the argument is true. For example:

=ExcludedState(Modulo(V0,2)=0)

This will set every other row to a case state value with the excluded flag turned on.

GVal(rgb_val) Extracts and returns the green value from an RGB color value.
Hidden(casestate_val) Returns true if the case state value argument has the Hidden flag set.
HiddenState(x) Returns a case state value with the Hidden flag set if the argument is true.
Labeled(casestate_val) Returns true if the case state value argument has the Labeled flag set.
LabeledState(x) Returns a case state value with the Labeled flag set if the argument is true.
Marked(casestate_val) Returns true if the case state value argument has the Marked flag set.
MarkedState(x) Returns a case state value with the Marked flag set if the argument is true.
MarkerOf(casestate_value) Returns the index of the Marker in the case state value argument. For example:

=MarkerOf(MarkerState(V0))

returns V0 (modulo 10, since there are 10 markers.)

MarkerState(n) Returns a case state value with the marker set to the nth marker, modulo 10.
Off(casestate_val) Returns true if the case state value argument has the Off state set.  Typically pass CaseState as the argument, for the case state of the current case.
OffState(x) Returns a case state value with the Off state set if the argument is true.
RGB(r,g,b) Constructs an RGB value from the integer arguments, which must be in [0,255]. For example:

RGB(0,0,0) is black

RGB(255,255,255) is white

ColorStateRGB(RGB(255,0,0)) returns a case state value with color red.

Internally, RGB values are stored as 32 bit integers in the hex form 0x00BBGGRR where BB is the 8 bit blue value from 0-255 decimal, etc.

RVal(rgb_val) Extracts and returns the red value from an RGB color value. For example:

RVAL(RGB(1,2,3)) is 1

GVAL(RGB(1,2,3)) is 2, etc.

SelCond Returns true if the current case is selected by the attached selection conditions (or if there are no such conditions)
Selected(casestate_val) Returns true if the case state value argument has the Selected flag set.
SelectedState(x) Returns a case state value with the Selected flag set if the argument is true.

See also: Distributions and their Functions, Spreadsheet Formulas - Overview, Spreadsheet Formulas - Syntax Summary, Spreadsheet Formulas - Examples, Spreadsheet Formulas - Syntax Operators, Spreadsheet Formulas - Distributions and their Functions.