Page tree

Release 8.2.2


Contents:

   

Contents:


Returns the maximum Datetime value of rows in each group that meet a specific condition. Set of values must valid Datetime values.


NOTE: When added to a transformation, this function is applied to the current sample. If you change your sample or run the job, the computed values for this function are updated. Transformations that change the number of rows in subsequent recipe steps do not affect the values computed for this step.

To calculate the maximum Datetime value of rows without conditionals, use the MAXDATE function. See MAXDATE Function.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

Basic Usage

maxdateif(incidentDate, serverFailure == 'true')

Output: Returns the maximum date from the incidentDate column when the value in the serverFailure column is true.

Syntax and Arguments

maxdateif(col_ref, test_expression) [group:group_col_ref] [limit:limit_count]


ArgumentRequired?Data TypeDescription
col_refYstringReference to the column you wish to evaluate. Values in the columns must be valid Date values.
test_expressionYstringExpression that is evaluated. Must resolve to true or false

For more information on syntax standards, see Language Documentation Syntax Notes.

For more information on the group and limit parameters, see Pivot Transform.

col_ref

Name of the column whose values you wish to use in the calculation. Inputs must be Datetime values.


Usage Notes:

Required?Data TypeExample Value
YesString that corresponds to the name of the columnmyDates

test_expression

This parameter contains the expression to evaluate. This expression must resolve to a Boolean (true or false) value.

Usage Notes:

Required?Data TypeExample Value
YesString expression that evaluates to true or false(LastName == 'Mouse' && FirstName == 'Mickey')


Examples


Tip: For additional examples, see Common Tasks.

Example - DATEIF Functions

This example illustrates how you can apply conditionals to calculate minimum, maximum, and most common date values:
  • MINDATEIF - Minimum of a set of Datetime values by group that meet a specified condition. See MINDATEIF Function.
  • MAXDATEIF - Maximum of a set of Datetime values by group that meet a specified condition. See MAXDATEIF Function.
  • MODEDATEIF - Most common Datetime value by group that meet a specified condition. See MODEDATEIF Function.

Source:

Here is some example transaction data:

DateProductUnitsUnitCostOrderValue
3/28/2020ProductA410.0040.00
3/8/2020ProductB420.0080.00
3/12/2020ProductC230.0060.00
3/23/2020ProductA110.0010.00
3/20/2020ProductB220.0040.00
3/12/2020ProductC930.00270.00
3/28/2020ProductA510.0050.00
3/23/2020ProductB820.00160.00
3/16/2020ProductC930.00270.00
3/8/2020ProductA510.0050.00
3/10/2020ProductB320.0060.00
3/13/2020ProductC130.0030.00
3/12/2020ProductA710.0070.00
3/10/2020ProductB720.00140.00
3/24/2020ProductC930.00270.00
3/15/2020ProductA810.0080.00
3/10/2020ProductB520.00100.00
3/10/2020ProductC430.00120.00


Transformation and Results:

These functions are useful for asking questions about your data. In the following, you can review specific questions and see the results immediately.

Question 1: What is the earliest date when a $100.00 transaction occurred?

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula mindateif(Date, OrderValue > 100)
Parameter: New column name 'Answers'

Results: Value in Answers column: 3/10/2020

Question 2: What is the latest date when a $200.00 transaction occurred?

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula maxdateif(Date, OrderValue > 200)
Parameter: New column name 'Answer'

Results: Value in Answers column: 3/24/2020

Question 3: On what date did the most transactions occur this month?

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula modedateif(Date, OrderValue > 0)
Parameter: New column name 'Answer'

Results: Value in Answers column: 3/10/2020

 

This page has no comments.