Amazon QuickSight – periodToDatePercentile
The ‘periodToDatePercentile()’ function is a statistical function in Amazon QuickSight that calculates the percentile of a measure for a given time period. This function is useful when you want to analyze how a measure changes over time and compare it to a certain percentile of data.
Syntax
#Start# periodToDatePercentile( measure, percentile, dateTime, period, endDate (optional) ) #End#
This function takes the following arguments:
- measure: This parameter specifies the measure for which you want to calculate the percentile. The measure can be a field or an expression.
- percentile: This parameter specifies the percentile that you want to calculate. The valid values for the percentile parameter are between 0 and 1, inclusive.
- dateTime: This parameter specifies the date and time for which you want to calculate the percentile. The parameter should be in the timestamp format.
- period: This parameter specifies the time period for which you want to calculate the percentile. The valid values for the period parameter are hour, day, week, month, quarter, and year.
- endDate (optional): This parameter specifies the end date and time of the time period. If this parameter is not specified, the current date and time will be used as the end date.
Suppose you have a sales dataset with the following fields: Date, Product, Sales, and Region. You can use the periodToDatePercentile() function to calculate the 90th percentile of sales for the current day by region. Here’s an example formula:
Example
#Start# periodToDatePercentile(Sales, 0.9, Date, 'day', now(), Region) #End#
This formula calculates the 90th percentile of the Sales field for the current day, grouped by Region. The now() function is used to specify the current date and time as the end date. This function can help you identify the highest sales values for the day in each region and compare them to the 90th percentile of the data.