This worksheet describes how to use contexts and filters to create a report that is tailored for a specific user. By setting a context, you can tailor the text and values in a report. By setting a filter, you can limit the data. In this worksheet, you add a list of comments to the report created in the worksheet Smart Reports: creating multiple pdf reports using contexts. The comments will be filtered so that they only include comments for a specific restaurant. This is done by applying a filter based on context to the list analysis.

The list analysis is added to the report RP1, along with a short description of the list. The description includes text based on the context, allowing you to tailor it for a recipient. You don’t want the description if there aren’t any comments, so the worksheet explains how to add the description conditionally. The N/A (not applicable) field holds the condition.

This worksheet assumes that you have worked through the worksheets Understanding contexts and Smart Reports: creating multiple pdf reports using contexts. It uses the Crocodile survey supplied with Snap which is assumed to be in the condition it would be in after completing these two worksheets. If you do not have it, a survey like that is available here.


As explained in the worksheet Understanding contexts, you can look at a subset of the data using a filter, or you can tag data of interest using a context.

If you only want to look at the data relevant to a specific context, you must use a filter based on a context. For example, one could set up a context variable of colour to filter mice.

If the context has been set to red, then you will have a subset of red mice to analyse.


When the context is changed, the subset automatically changes as well.


If no context has been applied, there will be no data to analyse.


The Not Applicable (N/A) field

Every report instruction has an N/A field. You can put a condition in the field saying when the instruction should not be used.


  • you can check if an analysis contains data and make the instruction not applicable if there is no data
  • you can use the N/A field to select between several different instructions, e.g, if you are producing a report for four different departments, you could set a condition based on context in the N/A field that excluded instructions that weren’t relevant to a department

The power of combining contexts and filters

The example report produced in this report uses a context of location. This allows you to generate separate reports with text and a benchmark analysis appropriate to the different locations. By adding further instructions to the report with filters based on the context, you can have analyses that only include the data specific to a given location.

You can filter a whole report based on context, but in that case, you cannot use any analyses that require the whole dataset, such as a comparison between the different locations.

Summary of steps

Step 1: Adding the filter to your comments list

There is already a list analysis of comments in the Crocodile surveyAN7.

  1. Click Results on the Snap toolbar to open the Analyses window. Select AN7 and click Clone on the analyses window toolbar to copy the list.
  2. It currently has a filter of Q8 ok applied. Add and Location=Location@context to filter the comments according to the current location (for each case, the value in Location must be the same as the current location set by the context).
    RD: base labels tab with report include area highlighted
  3. Select the Base/Labels tab.
  4. Clear the Reports Include options (DescriptionNotes and Title).
  5. Click [OK] to create the new list.

    Semantic Scale grid example stats definition

    It will be empty as no context has been applied (unless you have a global setting present in your survey).

  6. Select File|Context Values to open the Context Values dialog.

    Global context variable dialog

  7. Double click the global context value to open it. This allows you to set the context to a specific value.
  8. Set the Variable to Location and the Value to 1. This sets the current context to Bristol, UK.

    Global context variable dialog: location Bristol

  9. Click save to save the context.
  10. Click count on the analysis window toolbar to update the list. The comments for Bristol will appear.
  11. If you wish to check that the filter works for other contexts, open the global context value and set the value for Location to 2.
  12. Click count on the Global Context toolbar to update the context.
  13. Click count on the list analysis toolbar to update the list. The comments for London will appear.
  14. Click save to save the list.

Step 2: Adding a description for the comments to your report

This section uses the report RP1 created in the worksheet Smart Reports: creating multiple pdf reports using contexts.

  1. Click batch on the Snap toolbar to open the reports window.
  2. Double click the report RP1 to open it.
  3. Click once on the last instruction in the list to select it.
  4. Click add on the report dialog and select Information from the drop-down menu to add a new Information instruction after the last instruction.
  5. Enter the text “Comments received from customers at the ” in the large text area.
  6. Use the [Insert] button to open the Variable field... dialog.
  7. Select Location as the variable and set the Aspect as Context to insert the label of the current location.
  8. Finish the sentence by entering ” restaurant” in the text area.
    Information instruction showing context
  9. Click [OK] to save the instruction as instruction 5.

Step 3: Adding the comments list to your report

  1. Click add on the RP1 report dialog and select Execute from the drop-down menu to add a new Execute instruction.
  2. Click List down on the Execute dialog and select the AN18 (the comments list) from the list of analyses.
  3. Click [OK] to add the Execute instruction to the report.

Step 4: Setting when the text instruction will be used

It is possible that no comments will have been received for a restaurant. In this case, you do not want this text to appear. You can remove it by setting a N/A condition on the instruction.

  1. Double-click the information instruction (instruction 5) to open it.
  2. Type AN18 empty in the N/A field. This tests if there is currently any data in the comments list (analysis AN18). If there is not, the text instruction will not be used in the report.

    Information instruction showing contex

  3. Click [OK] to save your changes.

Step 5: Testing that the list is included correctly

As shown earlier, if there is no context set, the comments list will be empty.

  1. Open your report if it is not open and clear the Context field (delete the CXloc).

    Default summary report with context filter applied

  2. Select File|Context Values to open the Context Values dialog.

    Global context variable dialog

  3. Double click the global context value to open it. Delete the value of the Location variable to clear the context.
  4. Click Save to save the context.
  5. Change to the reports window.
  6. Select RP1 and click Go to run it. The Report Execution dialog opens.
  7. Click [Printer] to confirm that you are printing to the pdf printer driver. Click [OK] to close the Print Setup dialog.
  8. Click [OK] on the Report Execution dialog. It will produce a single report file entitled No reply. No comments will be visible and the instruction text will not be included.

    Smart reporting: image of

  9. Set the context for the report to CXloc and run the report again.
  10. Four reports will be included, each one with the appropriate text and comments.

    Smart reporting: image of


This worksheet has described how to use a filter based on a context to ensure the only data in the analysis is for the current context. It also explained what the N/A field is for and showed a simple example of use.

If you want to see how to filter the data for a report based on a context, see the topic Creating a sub-report that contains data specific to a context.

If you would like to see another example of including an instruction based on context, see Including an instruction based on context in a report.

If you would like to see the reference material for report instructions, see the Report definition dialog and the topics it links to.

If there is a topic you would like a worksheet on, email to