Trying to Create an Earliest Date Calculated Field

Hello All

I’m trying to create a calculated field that will return the field name of the column with the earliest date. I know the min function won’t work for this, but can’t figure-out an alternative.

Any suggestions appreciated.

Hi. Thanks you for your question! :slight_smile: Many of our community Experts and folks from our team are on holiday right now. I asked “My Assistant” (universal chat) in Quick, and got this back. @Brett Could you review and validate the answer below on Monday after you return from holiday?

From “My Assistant”:

”Here’s how to accomplish this in Amazon Quick:

Solution: Using minOver Function

To create a calculated field that shows the earliest (minimum) date across your dataset, you can use the minOver function. This is a table calculation function that calculates the minimum value of a measure or date field partitioned by specified dimensions.

Basic Syntax

minOver(
  {DateField},
  [partition_field, ...],
  calculation_level
)

Example: Finding the Earliest Date

For the earliest date across all rows:

minOver({YourDateField}, [], PRE_AGG)

For the earliest date by a specific group (e.g., by Customer):

minOver({OrderDate}, [{CustomerID}])

This will show the earliest order date for each customer.

Alternative Approaches

1. Using the min Aggregate Function

If you want the minimum date at the dataset level, you can use the simpler min function :

min({DateField})

You can also specify grouping levels:

min({DateField}, [Country])

This calculates the minimum date at the Country level.

2. Using periodToDateMin

If you need the minimum date within a specific time period (like year-to-date or month-to-date), use periodToDateMin :

periodToDateMin(
  min({DateField}),
  {DateField},
  "YYYY"
)

Important Considerations

  • Date fields work with min functions: Minimum date calculations are supported, but they only work in the Value field well of tables and pivot tables

  • Calculation level: Use PRE_AGG for pre-aggregate calculations or POST_AGG_FILTER (default) for table-level calculations

  • Data type: Ensure your date field is properly formatted as a date type in your dataset

Step-by-Step Instructions

  1. In your analysis, go to the Data pane and choose Add+ CALCULATED FIELD

  2. Name your field (e.g., “Earliest Date”)

  3. Enter your formula using one of the approaches above

  4. Choose Save

The calculated field will now be available to use in your visuals.”

Hi @hopeah

Kristin’s suggestion of minOver should do the work for you.

In addition, I am sharing the link to the Level aware calculations that should give you more detailed insights. I have found this blog quite useful when working with level aware calculations.

Regards,
Giri