This worksheet describes how to set up a Smart Report so it creates multiple pdf reports with Snap dynamically selecting the data depending on the context. It explains how to set up the survey in Snap so that it will produce all the reports that are needed, and then tells you how to set up the report instructions so that each report will be sent to a different pdf file.

This worksheet uses the sample Crocodile survey supplied with Snap. The survey evaluates a restaurant chain with four branches (two in the UK and two in the USA). The worksheet describes how to use the location in a context data set, allowing you to produce separate reports for each location.

The example starts with the report created in the worksheet Understanding contexts and shows you how to set it up so that a separate pdf file is produced for each restaurant manager, ready to be sent to them or printed out.

The worksheet assumes:


The worksheet Understanding contexts explained how to change what data was used depending on the information stored in a context variable and showed you how to set the current context by using the global data set.

The global data set allows you to set a context manually. You can also tell Snap to automatically create a report or an analysis multiple times by using a context data set.

This worksheet shows you how to set up a simple version of a context data set. It contains a single variable (Location) and tells Snap to use the received responses to work out how many reports or analyses to create. Snap looks at the raw data file (the responses received) and sets the context in turn to every value that has been received for the specified variable. For the Crocodile survey, if you placed the Location variable in a context data set, this would mean that if you had received responses from New York, Boston, London, but none from Bristol, reports would only be generated for New York, Boston and London, as there would be no responses in the raw data file with a value of Bristol, UK.

Creating separate files with a page layout instruction

When you create a report in Snap it is normally sent directly to the printer driver as a single file. If you wish to create separate files for the different contexts, you must set it up so it starts each version of the report on a new page, and places it in a new file.

The breaking up of the report is done using a Page Layout instruction. This tells Snap when to start a new page and when to start a new file.

Summary of steps

  1. Add the page layout instruction to your report
  2. Set up the context data set to create all the reports you need
  3. Run the report to generate the separate pdf files

Creating a context data set using the location variable

Snap can run reports for all locations if you create a Context data set.

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

    Context Values dialog

  2. Click add to create a new context.
  3. The Context Data Set dialog appears. By default it will have a name of CX1. Change this to CXloc. The CX will identify it as a context variable, and the loc tells you it is the location.
  4. Set the Type to Raw data. This uses data in the survey (the raw data file).
  5. Set the Label to Restaurant location so you know what the data set it for.
  6. Type Location in the Variables field. This tells Snap that the contexts are all the values in Location. (This assumes that you have changed the name of variable Q0 in the Crocodile file to Location as described in the worksheet Understanding contexts. If you have not, do so or use Q0.)

    CXloc Context Data Set

  7. Click save to save the context data set. You can now use it to automatically generate multiple reports.

Loop round all the context reports

  1. Open your report if it is not open and enter CXloc as the Context.

    Report RP1

  2. Click add on the report dialog and select Page Layout from the drop-down menu.
  3. Select Start New Page. This ensures that each time the report is run it starts on a new page.

    Report RP1 Instruction

  4. If the Page Layout instruction is not the first instruction in the report, select it in the window and drag it to the top of the list of instructions.
  5. Click Go to run the report. The Report Execution dialog opens.
  6. Click [Printer] to confirm that you are printing to the pdf printer driver. Click [OK] to close the Print Setup dialog.
  7. Click [OK] on the Report Execution dialog. It will produce a single report file with four versions of the content, one for each possible value of the variable listed in CXloc. Each one will start on a new page.


Setting up the report to create separate files

You need to modify the Page Layout instruction at the start of your report to tell Snap to save the different reports to separate files.

  1. Double-click the Page Layout instruction to open it.
  2. Select Restart Page numbers to ensure that each document starts on page 1.
  3. Select Start New Document. This places the report in a new file, (so each time it creates the report for the different context, it will start a new file).
  4. Click [Insert] and select Variable field from the list.
  5. Select Location as the Variable and Context as the Aspect. This will use the label of the Location for the current context as the filename, so the report for Boston will be given a filename of Boston, MA.pdf.

    New variable field

  6. Click [OK] to close the New Variable field dialog.

    Page Layout - Report RP1 - Instruction .

  7. Click [OK] to save your instruction.
  8. Click Go to run the report, then click [OK] on the Report Execution dialog. Depending on the pdf driver that you are using, and the way it has been set up, it will either automatically save or ask you to save the files. The picture below shows the four files in PDFCreator.
    PDF Creator - PDF Print monitor
  9. Once the files have been saved, you can check that they are as you expect. Snap should have created a report for each value of Location, and used the appropriate label as the filename.


This worksheet has described how to automatically change the context to create multiple versions of the report from the same data. It has also explained how to use a Page Layout instruction to create separate files, named according to the context, to store each report.

If you would like to see other examples of using contexts see Using contexts to provide personalised reports and questionnaires.

If you would like more examples of how to lay out a report, see the list of topics at Laying out your reports. For reference information about the page layout instruction, see the topic: Report instruction dialog: Page Layout: Page breaks tab.

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