Professional > Table scripting > Hierarchical data > Top 2 grid tables
 
Top 2 grid tables
Sample script file: Top2GridTable.mrs
This example script is based on the Museum sample data set. See Running the sample table scripts.
You can create a variable that includes the respondents that gave one of a set of answers (for example, the positive answers), for each iteration of a grid. This can be used to tabulate the percentage of respondents that had a positive opinion about the subject.
The following example shows how to create a variable that combines the top 2 categories for the grid.
TableDoc.DataSet.MdmDocument.Fields.AddScript("!
rating_Column_Top2_EvaluateGridSummary "rating[..].Column Top 2 Summary"
categorical [1..]
{
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 EvaluateGridSummary function returns the LevelID if the respondent chose one of the top 2 ratings. Combining this with the SUM function creates a variable that shows the number of respondents who chose one of the top 2 responses for each iteration.
This variable can then be added to the table.
TableDoc.Tables.AddNew("Table1", " * rating_Column_Top2_EvaluateGridSummary", "Top 2 using EvaluateGridSummary")
The script produces the following table.
See also
Hierarchical data