Skip to main content

period_to_date

info

This is part of our beta expression language AQL. Learn more. Request beta.

Definition

Calculates values for a specific time range up to the current date. For example, you can apply this computation to determine the total orders you have accumulated in sales from the beginning of the year up until the present date, also known as Year-to-Date(YTD) metric

Syntax

period_to_date(measure, date_part, date_dimension)
Examples
count(orders.id) | period_to_date('year', orders.created_at) // Return year-to-date total orders
count(orders.id) | period_to_date('month', orders.created_at) // Return month-to-date total orders

Input

  • measure (required): The measure on which you want to apply the period_to_date() function
  • date_part (required): The time period for which the measure should reset. It can be one of the following options. Can be one of the followings: 'year', 'quarter', 'month', 'week', 'day'
  • date_dimension (required): The date dimension that is used to determine the reset period

Output

A metric

Sample Usages

Year-to-date Total Orders per Quarter
explore {
dimensions {
orders.created_at | quarter()
}
measures {
count(orders.id) | period_to_date('year', orders.created_at)
}
}

Let us know what you think about this document :)