---
schema_version: "1"
id: 3ca103e4e5063debe238fcfad2c167215ffa749c39cce76aaec90a340f744f44
title: Modify the Query Results Based on the Dashboard Viewer
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/bi_dashboards_query_with_user_tokens.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.bi_dashboards_query_with_user_tokens.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: dd8e1ce38c964e43fa431edaef00f93e7f41f5a1caf70a1b766eb98d09130539
description: You can modify a query based on the user viewing the dashboard. For example, you can filter opportunity records to show only those opportunities owned by this user.
products:
  - CRM Analytics
  - Cross Cloud
release: "264"
---
# Modify the Query Results Based on the Dashboard Viewer

You can modify a query based on the user viewing the dashboard. For example, you can filter opportunity records to show only those opportunities owned by this user.

You can specify user tokens in any query parameter in `saql`, `soql`, and `aggregateflex` query types. The syntax to specify a token is: `!{user.<User object field name>}`. Valid tokens are: `user.Id`, `user.name`, `user.roleid`, and `user.rolename`.

![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_tip.png)

Tip Because names aren’t always unique, consider using IDs when specifying a user token.

This `saql`\-type query adds the `user.Id` token as a query filter so that opportunity owners viewing the dashboard see only their opportunities.

```javascript
"My_Opportunities_1": {
    "type": "saql",
    "label": "My Opportunities",
    "query": "q = load "opportunity";\nq = filter q by 'OwnerId' == "!{user.Id}";\nq = group q by 'Account.Type';\nq = foreach q generate 'Account.Type' as 'Account.Type', count() as 'count';\nq = order q by 'count' desc;\nq = limit q 1000;",
    "datasets": [
        {
            "id": "0FbB000000017QxKAI",
            "name": "opportunity",
            "label": "Opportunities",
            "url": "/services/data/v41.0/wave/datasets/0FbB000000017QxKAI"
        }
    ],
    "useGlobal": true,
    "isGlobal": false,
    "broadcastFacet": true,
    "receiveFacet": true,
    "selectMode": "single",
    "numbers": [],
    "groups": [],
    "strings": [],
    "visualizationParameters": {
        ....
    },
},
```

#### See Also

- [Set Initial Selections in the Dashboard](https://help.salesforce.com/s/articleView?id=analytics.bi_dashboard_initial_filters_pick.htm&release=264.0.0&type=5 "If the CRM Analytics dashboard contains selection-based widgets (chart, date, list, range, or toggle), you can set initial selections that are applied when the dashboard first opens. For example, you can select a bar in a bar chart and set that as the initial selection. If the underlying query for the bar chart is faceted, other widgets with faceted queries are filtered based on this initial selection. While viewing the dashboard, a user can change the selection in the chart to filter the results differently or remove the selection and filters altogether.")