ANY |
The ANY function returns YES when any values of a Boolean expression are TRUE, or NO when none of the values of the expression are TRUE.
Return Value
BOOLEAN.
Syntax
ANY(boolean-expression [dimensions])
Arguments
The Boolean expression to be evaluated
The dimensions of the result. By default, ANY returns a single YES or NO value. When you indicate one or more dimensions for the result, ANY tests for TRUE values along the dimensions that are specified and returns an array of values. Each dimension must be either a dimension of boolean-expression or related to one of its dimensions. When it is a related dimension, you can specify the name of the relation instead of the dimension name. This makes it possible for you to choose which relation is used when there is more than one.
Notes
The Effect of NASKIP on ANY
ANY is affected by the NASKIP option. When NASKIP is set to YES (the default), ANY ignores NA values and returns YES when any of the values of the expression that are not NA are TRUE and returns NO when none of the values are TRUE. When NASKIP is set to NO, ANY returns NA when any value of the expression is NA. When all the values of the expression are NA, ANY returns NA for either setting of NASKIP.
Data with a Type of DAY, WEEK, MONTH, QUARTER, or YEAR
When boolean-expression is dimensioned by a dimension with a type of DAY, WEEK, MONTH, QUARTER, or YEAR, you can specify any other dimension of this type as a related dimension. Oracle OLAP uses the implicit relation between these dimensions. To control the mapping of one of these dimension to another (for example, from weeks to months), you can define an explicit relation between the dimensions and specify the name of the relation as the dimension argument to the ANY function.
For each time period in the related dimension, Oracle OLAP tests the data values for all the source time periods that end in the target time period. This method is used regardless of which dimension has the more aggregate time periods.
Examples
Testing for Any True Values by District
Suppose you want to find out which districts had at least one month with sales greater than $150,000 for sportswear. You use the ANY function to determine whether the Boolean expression (sales GT 150000) is TRUE for any month. To have the result dimensioned by district, specify district as the second argument in the ANY function.
LIMIT product TO 'SPORTSWEAR' REPORT HEADING 'High Sales' ANY(sales GT 150000, district)
The preceding statements produce the following output.
DISTRICT High Sales -------------- ---------- Boston NO Atlanta YES Chicago NO Dallas YES Denver NO Seattle NO
Testing for Any True Values by Region
You might also want to find out which regions had at least one month in which at least one district had sportswear sales greater than $150,000. Since the region dimension is related to the district dimension, you can specify region instead of district as a dimension for the results of ANY.
report heading 'High Sales' any(sales gt 150000, region)
The preceding statement produces the following output.
REGION High Sales -------------- ---------- East YES Central YES west NO