def create_extra_dimensions_stats(customer_records_by_extra_dim):
    """Groups entry records by customer_id and extra_dimension.

    Args:
        customer_records_by_extra_dim: Tuple containing a tuple of customer_id
            and extra_dimension and a list of transaction records related to
            that combination

    Returns:
        Tuple containing statistics for the customer and extra dimension.
    """
    (customer_id, extra_dimension), records = customer_records_by_extra_dim

    dimension_count = 0
    tot_sales = 0.0
    max_dimension_date = None
    for r in records:
        dimension_count += 1
        tot_sales += r[3]
        if not max_dimension_date or r[2] > max_dimension_date:
            max_dimension_date = r[2]

    return customer_id, extra_dimension, dimension_count, tot_sales, \
           max_dimension_date