> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Use a dataset with a monitor

Datasets are available on Postman Solo, Team, and Enterprise plans. For more information, see the [pricing page](https://www.postman.com/pricing/).

You can use a Postman [dataset](/docs/tests-and-scripts/datasets/overview/) and its views as iteration data for a [monitor](/docs/monitoring-your-api/setting-up-monitor) run. Every row returned by the selected view becomes one collection iteration, available through `pm.iterationData`. Datasets are shared across workflows, so the same data can power collection runs, code mocks, and monitors without duplication. Because a monitor resolves the current dataset view each time it runs, scheduled tests can use the latest data without re-uploading files. To access local data files or external data sources with a monitor, you must use a [Private API Monitoring runner](/docs/monitoring-your-api/runners/overview/).

Monitors in Cloud View can only access datasets with Postman Cloud Store data sources.

## Prepare your collection

Add [variables](/docs/use/send-requests/variables/variables/) to the requests in your collection. Variable names should match the field names exposed by the view you select. For example, if your view includes a `userId` field, reference it as `{{userId}}` in a request URL. [Create a dataset](/docs/tests-and-scripts/datasets/create-datasets/) with at least one view that returns the data you want to use.

During a monitor run, the view's field values are also available in pre-request and post-response scripts through `pm.iterationData`. Learn more about [using iteration data variables in scripts](/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-variables/#pmiterationdata).

```js
const token = pm.iterationData.get('token');
pm.request.headers.upsert({
    key: 'Authorization',
    value: `Bearer ${token}`
});
```

You can also use the `pm.datasets` function to run saved views or run read-only SQL queries in scripts while a monitor is running. Learn more at [Manage and use datasets in scripts](/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-datasets/).

## Use a dataset with a monitor

When you configure a monitor, you can select a dataset view to provide iteration data for the monitor run. You must use [Private API Monitoring runners](/docs/monitoring-your-api/runners/overview/) to access local data files or external data sources.

To select a dataset when configuring a monitor, do the following:

1. [Create or edit a monitor](/docs/monitoring-your-api/setting-up-monitor/#configure-a-monitor).

2. Under **Iteration data**, click the dropdown list and select a dataset view. Optionally, click <img alt="Add icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-add-stroke.svg#icon" width="20px" /> **New dataset** to create one without leaving the monitor configuration.

   A preview of the dataset view appears in the right pane. From here, you can do the following:

   * Edit the view and click **Run** to preview the results.
   * Click **Save** to save your changes to the view.
   * Click **Set as new view** to save the changes as a separate view. The monitor automatically switches to the new view.
   * Click **Reset** to discard changes and return to the original view.

3. Select an **Iteration strategy** for the run. Learn more about [iteration strategies](#iteration-strategies).

4. Enter the number of iterations. Not available for the **Default** iteration strategy.

5. Complete the remaining monitor configuration and save the monitor.

## Iteration strategies

An iteration strategy determines what happens when the number of configured iterations differs from the number of rows returned by the selected view.

* **Default** — The monitor runs one iteration for each row returned by the view.
* **Round robin** — If iterations exceed the number of rows, the monitor starts again from the first row for the remaining iterations.
* **Repeat last** — If iterations exceed the number of rows, the monitor reuses the last row for the remaining iterations.
* **Stop at end** — The monitor stops when it runs out of rows, regardless of the configured number of iterations.