Skip to main content

Use case

Sometimes, you might need to group the result set by units of time that are different from default granularities such as week (starting on Monday) or year (starting on January 1). Below, we explore the following examples of custom granularities:
  • Week starting on Sunday, commonly used in the US and some other countries.
  • Fiscal year and fiscal quarter, commonly used in accounting and financial reporting.

Data modeling

Consider the following data model. interval and offset parameters are used to configure each custom granularity in granularities. Note that each custom granularity is also exposed via a proxy dimension. This is not just a convenience: while the REST API can query custom granularities by name, the SQL API and the GraphQL API can only address the default granularities, so a proxy dimension is the way to query a custom granularity from those APIs or from a BI tool. Proxy dimensions can also be used in further calculations, like rendering fiscal_quarter_label below.

Result

Querying this data modal would yield the following result: