Queries
Example queries
Queries are plain objects, describing an analytics query. The basic elements of a query (query members) are measures
and dimensions
.
In the case of dimension of type time granularity could be optionally added to the name.
Supported granularities: day
, week
, month
, quarter
and year
.
A Query has the following properties:
measures
: An array of measures.dimensions
: An array of dimensions.filters
: An array of objects, describing filters.timeDimensions
: A convenient way to specify a time dimension with a filter. It is an array of objects in [timeDimension format.]limit
: A row limit for your query. The default value is10000
. The maximum allowed limit is50000
.offset
: The number of initial rows to be skipped for your query. The default value is0
.order
: An object, where the keys are measures or dimensions to order by and their corresponding values are eitherasc
ordesc
. The order of the fields to order on is based on the order of the keys in the object.-
timezone
: All time based calculations performed within Cube.js are timezone-aware. This property is applied to all time dimensions during aggregation and filtering. It isn't applied to the time dimension referenced in adimensions
query property unless granularity or date filter is specified. Using this property you can set your desired timezone in TZ Database Name format, e.g.:America/Los_Angeles
. The default value isUTC
.{ measures: ['Stories.count'], dimensions: ['Stories.category'], filters: [{ member: 'Stories.isDraft', operator: 'equals', values: ['No'] }], timeDimensions: [{ dimension: 'Stories.time', dateRange: ['2015-01-01', '2015-12-31'], granularity: 'month' }], limit: 100, offset: 50, order: { 'Stories.time': 'asc', 'Stories.count': 'desc' }, timezone: 'America/Los_Angeles' }
Kitelinks
Properties
MY-LINK-SLUG
Refers to the slug of a Kitelink. If your Kitelink is https://kite.link/pk-ted-climate-mindset, then your link slug is pk-ted-climate-mindset
.
All-time Views
{
"measures": ["KitelinksBasicAnalytics.linkViewCount"],
"timeDimensions": [
{
"dimension": "KitelinksBasicAnalytics.timestamp",
"dateRange": ["2000-01-01", "2050-01-01"]
}
],
"filters": [
{
"member": "KitelinksBasicAnalytics.link",
"operator": "equals",
"values": [
"MY-LINK-SLUG"
]
}
]
}
Unique Views by Day
{
"measures": ["KitelinksBasicAnalytics.uniqueLinkViewCount"],
"timeDimensions": [
{
"dimension": "KitelinksBasicAnalytics.timestamp",
"granularity": "day",
"dateRange": "This month"
}
],
"order": {
"KitelinksBasicAnalytics.timestamp": "asc"
},
"filters": [
{
"member": "KitelinksBasicAnalytics.uniqueLinkViewCount",
"operator": "notEquals",
"values": ["0"]
},
{
"member": "KitelinksBasicAnalytics.link",
"operator": "equals",
"values": [
"MY-LINK-SLUG"
]
}
]
}
Views by Day
{
"measures": ["KitelinksBasicAnalytics.linkViewCount"],
"timeDimensions": [
{
"dimension": "KitelinksBasicAnalytics.timestamp",
"granularity": "day",
"dateRange": [
"2022-07-01",
"2022-07-30"
]
}
],
"order": {
"KitelinksBasicAnalytics.timestamp": "asc"
},
"filters": [
{
"member": "KitelinksBasicAnalytics.linkViewCount",
"operator": "notEquals",
"values": ["0"]
},
{
"member": "KitelinksBasicAnalytics.link",
"operator": "equals",
"values": [
"MY-LINK-SLUG"
]
}
]
}
Clicks by Link
{
"measures": ["KitelinksAdvancedAnalytics.openLinkViewCount"],
"timeDimensions": [
{
"dimension": "KitelinksAdvancedAnalytics.timestamp",
"dateRange": [
"2022-07-01",
"2022-07-30"
]
}
],
"order": [["KitelinksAdvancedAnalytics.openLinkViewCount", "desc"]],
"dimensions": ["KitelinksAdvancedAnalytics.openParam"],
"filters": [
{
"member": "KitelinksAdvancedAnalytics.openParam",
"operator": "set"
},
{
"member": "KitelinksAdvancedAnalytics.openLinkViewCount",
"operator": "notEquals",
"values": ["0"]
},
{
"member": "KitelinksBasicAnalytics.link",
"operator": "equals",
"values": [
"MY-LINK-SLUG"
]
}
]
}