Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Derived variables > Dynamically derived variables > Creating a boolean derived variable
 
Creating a boolean derived variable
You can modify the mrScriptBasic example to create a Boolean dynamically derived variable, which you could use, for example, as a filter variable in UNICOM Intelligence Reporter or InterviewReporter.
To set up a derived Boolean variable called DinosaurFreak, make the following changes to the mrScriptBasic example shown above:
1 Change the variable name and label:
Set MyDynamicallyDerivedVariable = _
MyDocument.CreateVariable("DinosaurFreak", "Really likes dinosaurs")
2 Change the DataType to Boolean:
MyDynamicallyDerivedVariable.DataType = mr.Boolean
3 Change the expression:
MyDynamicallyDerivedVariable.Expression = _
"time_spent.ContainsAny({whole_day}) AND " + _
"remember.ContainsAny({dinosaurs},1) AND " + _
"prefer.ContainsAny({prefer_dinosaurs}) AND " + _
"interest.ContainsAny({dinosaurs})"
4 Use the derived Boolean variable as a handy filter variable in DM Query, by running this query:
SELECT serial FROM vdata WHERE DinosaurFreak
DM Query returns one column of data containing only one case:
serial
370
370 is the serial number of the only respondent in the Museum data set who meets the requirements of the DinosaurFreak filter.
See also
Dynamically derived variables