/    /  Amazon QuickSight – periodToDateMax

Amazon QuickSight – periodToDateMax

 

Amazon QuickSight is a cloud-based business intelligence and data visualization tool developed by Amazon Web Services. The periodToDateMax function is used to calculate the maximum value of a measure or metric for a given period up to a specified date/time.

 

Syntax

#Start#
periodToDateMax(measure, dateTime, period, endDate)
#End#

 

This function takes the following arguments:

 

  • measure: This is the name of the measure or metric that you want to calculate the period-to-date maximum for.
  • dateTime: This is the date/time for which you want to calculate the period-to-date maximum.
  • period: This is the period for which you want to calculate the maximum. The period can be any one of the following: “hour”, “day”, “week”, “month”, “quarter”, or “year”.
  • endDate (optional): This is the end date of the time series. If you omit this parameter, the function uses the current date as the end date.

 

 

Here’s an example that illustrates how to use the periodToDateMax function in QuickSight:

 

Suppose you have a dataset that contains sales data for a retail store, and you want to calculate the maximum sales amount for each month up to the current date. You can use the following expression:

Example

#Start#
periodToDateMax(Sales, OrderDate, "month")
#End#

 

In this expression, Sales is the name of the measure that you want to calculate the period-to-date maximum for, OrderDate is the date/time field in the dataset that contains the order date for each sale, and “month” is the period that you want to calculate the maximum for.

 

If you want to calculate the period-to-date maximum up to a specific end date, you can include the endDate parameter in the function. For example, to calculate the maximum sales amount for each week up to the end of the current quarter, you can use the following expression:

Example

#Start#
periodToDateMax(Sales, OrderDate, "week", "2023-03-31")
#End#

 

In this expression, “2023-03-31” is the end date of the current quarter.