Survey Tabulation > Advanced expressions > 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.
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 may 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
Val may refer to any type of MDM object that has elements, for example, Field, Array, Grid or VariableInstance, or it may 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.
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.
For more information, see Quanvert DSC.
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
For additional SQL query information, see Advanced SQL queries.
See also
Categorical functions