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
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.

"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": {
        ....
    },
},