================================================================================
UPPERLIMIT with FILTER function in field references test
================================================================================

table 2632 "Test Table"
{
    fields
    {
        field(31; "Balance at Date"; Decimal)
        {
            CalcFormula = sum("Ledger Entry".Amount where("Account No." = field("No."),
                                                        "Date" = field(upperlimit(filter("Date Filter")))));
            FieldClass = FlowField;
        }
        field(32; "Net Change"; Decimal)
        {
            CalcFormula = Sum("Ledger Entry".Amount where("Account No." = field("No."),
                                                        "Date" = field(UPPERLIMIT(FILTER("Date Filter")))));
            FieldClass = FlowField;
        }
        field(33; "Other Balance"; Decimal)
        {
            CalcFormula = sum("Ledger Entry".Amount where("Account No." = field("No."),
                                                        "Date" = field(Upperlimit(Filter("Date Filter")))));
            FieldClass = FlowField;
        }
    }
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (fields_section
      (fields_keyword)
      (field_declaration
        id: (integer)
        name: (quoted_identifier)
        type: (type_specification
          (basic_type))
        (property
          name: (property_name)
          value: (aggregate_formula
            function: (aggregate_function)
            target: (calc_field_reference
              (quoted_identifier)
              (identifier))
            (where_clause
              (where_conditions
                (where_condition
                  field: (quoted_identifier)
                  value: (quoted_identifier))
                (where_condition
                  field: (quoted_identifier)
                  (filter_keyword)
                  value: (quoted_identifier))))))
        (property
          name: (property_name)
          value: (identifier)))
      (field_declaration
        id: (integer)
        name: (quoted_identifier)
        type: (type_specification
          (basic_type))
        (property
          name: (property_name)
          value: (aggregate_formula
            function: (aggregate_function)
            target: (calc_field_reference
              (quoted_identifier)
              (identifier))
            (where_clause
              (where_conditions
                (where_condition
                  field: (quoted_identifier)
                  value: (quoted_identifier))
                (where_condition
                  field: (quoted_identifier)
                  (filter_keyword)
                  value: (quoted_identifier))))))
        (property
          name: (property_name)
          value: (identifier)))
      (field_declaration
        id: (integer)
        name: (quoted_identifier)
        type: (type_specification
          (basic_type))
        (property
          name: (property_name)
          value: (aggregate_formula
            function: (aggregate_function)
            target: (calc_field_reference
              (quoted_identifier)
              (identifier))
            (where_clause
              (where_conditions
                (where_condition
                  field: (quoted_identifier)
                  value: (quoted_identifier))
                (where_condition
                  field: (quoted_identifier)
                  (filter_keyword)
                  value: (quoted_identifier))))))
        (property
          name: (property_name)
          value: (identifier))))))
