---
schema_version: "1"
id: 6156cd5ca72811537689ad19370e379fdae828b3db0b70b01be3a259f545b5e6
title: rules.json Example
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_wave_templates/guides/reference/bi-templatesdev-rules-json-example.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-rules-json-example.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0e12cceb2d24712145c80a8588b718855ebe5c6257f4a019dca6054f407fe067
products:
  - Analytics Templates Developer Guide
  - analytics
---

# rules.json Example

Refer to this example of the `rules.json` file.

## Example

```nolang
{
   "constants":[
      {
         "name":"ChartType",
         "value":"pie"
      }
   ],
   "rules":[
      {
         "name":"rule1",
         "appliesTo":[
            "type":"dashboard",
            "name":"dashboardOne",

         ],
         "actions":[
            {
               "action":"put",
               "description":"Put a section back in, but with different attributes",
               "path":"$.state.widgets.chart_1",
               "key":"pos",
               "value":{
                  "w":"501",
                  "y":"41",
                  "h":"121",
                  "x":"51"
               }
            },
            {
               "action":"delete",
               "description":"Delete a section",
               "path":"$.state.widgets.chart_2"
            }
         ]
      }
   ]
```

The corresponding `dashboardOne.json` file that uses the above rules files looks like:

```nolang
{
    "_type": "dashboardTemplate",
    "name": "Dashboard From Template With Rules",
    "edgemarts": {
        "${Variables.Dataset1.datasetAlias}": {
            "_type": "edgemart",
            "_uid": "${Variables.Dataset1.datasetId}"
        },
        "${Variables.Dataset2.datasetAlias}": {
            "_type": "edgemart",
            "_uid": "${Variables.Dataset2.datasetId}"
        }
    },
    "folder": {
        "_type": "folder",
        "_uid": "${App.Folder.Id}"
    },
    "tags": [

    ],
    "state": {
        "widgets": {
            "chart_1": {
                "params": {
                    "chartType": "${Constants.ChartType}",
                    "minColumnWidth": 30,
                    "maxColumnWidth": 200,
                    "legend": false,
                    "selectMode": "single",
                    "sqrt": false,
                    "legendHideHeader": false,
                    "legendWidth": 145,
                    "step": "step_1"
                },
                "type": "ChartWidget",
                "pos": {
                    "w": "500",
                    "y": 60,
                    "h": "120",
                    "x": 40
                }
            },
            "chart_2": {
                "params": {
                    "chartType": "${Constants.ChartType}",
                    "minColumnWidth": 30,
                    "maxColumnWidth": 200,
                    "legend": false,
                    "selectMode": "single",
                    "sqrt": false,
                    "legendHideHeader": false,
                    "legendWidth": 145,
                    "step": "step_2"
                },
                "type": "ChartWidget",data
                "pos": {
                    "w": "500",
                    "y": 190,
                    "h": "120",
                    "x": 40
                }
            }
        },
        "steps": {
            "step_1": {
                "isFacet": true,
                "start": null,
                "query": {
                    "measures": [
                        [
                            "count",
                            "*"
                        ]
                    ]
                },
                "selectMode": "single",
                "useGlobal": true,
                "em": "${Variables.Dataset1.datasetId}",
                "type": "aggregate",
                "isGlobal": false
            },
            "step_2": {
                "isFacet": true,
                "start": null,
                "query": {
                    "measures": [
                        [
                            "count",
                            "*"
                        ]
                    ]
                },
                "selectMode": "single",
                "useGlobal": true,
                "em": "${Variables.Dataset2.datasetId}",
                "type": "aggregate",
                "isGlobal": false
            }
        },
        "type": "hbar"
    }
}
```

When the rules are applied to the dashboard, the `chart_1` widget will have a chartType of “pie” and the “pos” will be updated to w=501, y=41, h=121, and x=51. The `chart_2` widget will be removed.
