Scripting > UNICOM Intelligence Function Library > Miscellaneous functions > EvaluateGridSummary
 
EvaluateGridSummary
The EvaluateGridSummary function makes it easier to create variables that show the number of respondents that chose a specified response for a grid iteration, for example a Top 2 variable showing the number of respondents who gave a positive answer for each iteration of a grid.
This function is useful when per element bases are required to tabulate the percentage of respondents choosing that response using a base of those respondents who gave a response for the grid iteration.
The function is useful only when using the up-lev operator, for example:
SUM(rating.(EvaluateGridSummary(Column, {Very_interested_5, Slightly_interested_4}, LevelID, False)))"
Syntax
EvaluateGridSummary(Val, CategoriesOfInterest, LevelID, IncludeBase)
Parameters
Val
Type: None
Variant value. Specifies which grid subfield to use.
CategoriesOfInterest
Type: Categorical
Categories of interest. If these categories were chosen by the respondent, the function returns the LevelID.
LevelID
Type: None
Variant value. Specifies the LevelID, also known as the grid iterator, typically LevelID.
IncludeBase
Type: Boolean
True evaluates per element bases (they must be in the metadata). This might be relevant if the grid is filtered.
(return)
Type: Categorical
If the response to the Val subfield contains the categories of interest, the return value is the LevelID category. If IncludeBase is True, the LevelID category with "Base" appended is included in the returned categorical value.
If the response to Val subfield does not contain any categories, the return value is Null.
Example 1
This tables scripting example adds script to create a top 2 variable for a rating grid. The metadata script includes a base that filters out any respondents who do not have any responses for the grid iteration. The top 2 variable can then be added to a table.
TableDoc.DataSet.MdmDocument.Fields.AddScript("!
rating_Column_Top2_EvaluateGridSummary "rating[..].Column Top 2 Summary"
categorical [1..]
{
Base "Base" elementtype(AnalysisBase) expression("rating_Column_Top2_EvaluateGridSummary > {}"),
Fish_and_reptiles "Fish and reptiles",
Birds "Birds",
Insects "Insects",
Mammals "Mammals",
"Other" "Other"
} expression("SUM(rating.(EvaluateGridSummary(Column, {Very_interested_5, Slightly_interested_4}, LevelID, False)))", NoDeriveElements);
!")
Set Field = TableDoc.DataSet.MdmDocument.Fields["rating_Column_Top2_EvaluateGridSummary"]
TableDoc.Variables.Add(Field)
The category names (category IDs) for the categorical question must match the iterations of the referenced grid (rating).
The EvaluateGridSummary expression returns the LevelID (the iteration category) where the respondent chose Very_interested_5 or Slightly_interested_4.
The SUM expression returns the list of LevelIDs (iteration categories) where the respondent chose the categories of interest.
Example 2
This example sets the IncludeBase parameter to True to support per element bases. The per element bases must be in the metadata.
TableDoc.DataSet.MdmDocument.Fields.AddScript("!
rating_Column_Top2_WithBases "rating[..].Column Top 2 Summary"
categorical [1..]
{
Base "Base" elementtype(AnalysisBase) expression("rating_Column_Top2_WithBases > {}"),
Fish_and_reptiles_Base "Fish and reptiles Base" [Hidden=True] elementtype(AnalysisBase),
Fish_and_reptiles "Fish and reptiles",
Birds_Base "Birds Base" [Hidden=True] elementtype(AnalysisBase),
Birds "Birds",
Insects_Base "Insects Base" [Hidden=True] elementtype(AnalysisBase),
Insects "Insects",
Mammals_Base "Mammals Base" [Hidden=True] elementtype(AnalysisBase),
Mammals "Mammals",
Other_Base "Other Base" [Hidden=True] elementtype(AnalysisBase),
"Other" "Other"
} expression("SUM(rating.(EvaluateGridSummary(Column, {Very_interested_5, Slightly_interested_4}, LevelID, True)))", NoDeriveElements);
!")
The category names (category IDs) for the categorical question must match the iterations of the referenced grid (rating).
The category names (category IDs) for the base categories must be in this format:
IterationCategoryName_base
For example: Fish_and_reptiles_Base
The EvaluateGridSummary expression returns the category IterationCategoryName_base if the respondent answered the iteration. It also returns the LevelID (the iteration category) where the respondent chose Very_interested_5 or Slightly_interested_4.
The SUM expression returns the list of LevelIDs (iteration categories) where the respondent chose the categories of interest and the list of base categories where the respondent answered the iteration.
See also
Miscellaneous functions