Developer Documentation Library > Scripting > UNICOM Intelligence Function Library > Categorical functions > DefinedElements
 
DefinedElements
Returns a set of elements of a categorical variable.
Syntax
DefinedElements(Val [, Types])
Parameters
Val
Type: Categorical
Categorical value, used only to specify which MDM object to use.
Val can refer to any type of MDM object that has elements, for example, Field, Array , Grid or VariableInstance, or it can be an Elements list itself.
If the current value is NULL, Val is an empty Categorical value {} and the return value is also an empty Categorical value.
Types
Type: Long
Optional. Flags specifying which types of Element objects to include. The default is (Category + Base). The possible values for Types are shown in the following table.
Value
Description
1
Category elements
2
Base elements
4
Subtotal elements
8
Summary data elements
16
Derived elements
32
Subheading elements
The flags can be used in any combination, to select elements of more than one type. For example, to select all Category and Base elements, use 1 + 2 = 3.
(return)
Type: Categorical
Set of category numbers as defined in the VariableInstance.
Remarks
This function requires the case data to be opened with an MDM document or for a script to have an open MDM document available to it. Otherwise, an error will occur. For more information about opening a MDM document in a script, see Value resolution.
Like DefinedCategories, DefinedElements is typically used to define groups in SQL queries. However, whereas DefinedCategories defines groups based on categories only, you can use DefinedElements to define groups based on any element type that stores case data or a combination of these element types.
Examples
The following query creates groups based on all categories and any base elements in the gender and gender.Ex variables in the Museum Quanvert sample data base. The gender.Ex variable is included in the GROUP BY statement because Quanvert DSC stores special elements in a separate variable that has an .Ex suffix. See Quanvert DSC for more information.
SELECT groupby.col[0] AS Gender,
  SUM(visits) AS 'Sum of visits'
FROM vdata
WHERE visits > 0
GROUP BY gender.EX + gender
  ON gender.Ex.Definedelements() + gender.Definedelements()
Here is the result set:
Gender Sum of visits
{base} 2131
{male} 1309
{female} 822
See Advanced SQL queries for additional SQL query information.
See also
Categorical functions