source Step Type Properties

Use the sources property to add columns, groups, filters, and formulas to a step query.

Field NameDescription
columnsThe columns for the source. For more information, see columns Properties.
groupsThe dimensions to group the data in the source.
filtersThe filters applied to the columns in the source. For more information, see filters Properties
nameThe name of the data source. If the query has formula columns, they’re added as the last source without the name property.
cogroupTypeWhen there are multiple data sources with different name properties, this parameter is used to define which records are included in the blended data for this query. Valid values for cogroupType are left, right inner full. For left and right blends, the initial dataset or blend is considered the left one. For more information on data blending, see Explore Multiple Datasets with a Single Query.

Example: Grain Query 

1"sources": [
2    {
3        "columns": [
4          {
5            "field": "Customer_Name",
6            "name": "Customer_Name"
7          },
8          {
9            "field": "Customer_Segment",
10            "name": "Customer_Segment"
11          },
12          {
13            "field": "Product_Name",
14            "name": "Product_Name"
15          },
16          {
17            "field": "City",
18            "name": "City"
19          },
20          {
21            "field": "Order_ID",
22            "name": "Order_ID"
23          },
24        ],
25        "groups": [],
26        "filters": [],
27        "name": "SuperStoreSales"
28    }
29]

Example: Query without groupings 

When a query isn’t grouped by a dimension, set groups to ["all"]

1"sources": [
2    {
3        "columns": [
4          {
5            "field": ["sum", "Amount"]
6            "name": "A"
7          },
8        ],
9        "groups": ["all"],
10        "filters": [],
11        "name": "SuperStoreSales"
12    }
13]

Example: Query with groupings 

1"sources": [
2    {
3        "columns": [
4          {
5            "field": ["sum", "Amount"]
6            "name": "A"
7          },
8        ],
9        "groups": ["Customer_Segment", "Order_priority"],
10        "filters": [],
11        "name": "SuperStoreSales"
12    }
13]

Example: Query with formula column 

1"sources": [
2    {
3        "columns": [
4          {
5            "field": ["sum", "Amount"]
6            "name": "A"
7          },
8          {
9            "formula": "case \nwhen starts_with('Product_Container', \"Small|") then null\nelse count()\nend\n",
10            "name": "B"
11          }
12        ],
13        "filters": [],
14        "groups": [
15            "Order_Priority",
16            "Product_Container"
17        ],
18        "name": "SuperStoreSales"
19    }
20]

Example: Query with columns referencing formulas 

Formula columns are defined in a separate source without a name property.

1"sources": [
2    {
3        "columns": [
4          {
5            "field": ["sum", "Amount"]
6            "name": "A"
7          }
8        ],
9        "groups": ["Customer_Segment", "Order_Priority"],
10        "filters": [],
11        "name": "SuperStoreSales"
12    },
13    {
14        "columns": [
15          {
16            "forumula": "A*2",
17            "name": "B"
18          },
19          {
20            "forumula": "B/100",",
21            "name": "C"
22           }
23         ]
24    }
25]

Example: Query with multiple data sources 

1"sources": [
2    {
3        "columns": [
4          {
5            "field": ["avg", "Profit"]
6            "name": "A"
7          }
8        ],
9        "groups": ["City"],
10        "filters": [],
11        "name": "SuperStoreSales",
12        "cogroupType": "left"
13    },
14    {
15        "columns": [
16          {
17            "field": ["sum", "Amount"],
18            "name": "B"
19          }
20        ],
21        "groups": ["City"],
22        "filters": [],
23        "name": "Opportunity"
24    }
25]