# NumberDropDownFields property

The number drop-down fields of this form group as an array.

Accessing all number drop-down fields of a form group through this property has many uses:

- Calculating the sum of all number drop-down fields of a form group.
- Enabling a button only if all number drop-down fields of a form group are valid.
- Deciding which background color to use based on whether the number drop-down fields of a form group are valid.
- Collecting the labels and values of all number drop-down fields of a form group as a text string, for use as the body of an email.
- Only allowing a user to move forward to the next screen if they have filled out all number drop-down fields of a form group.

The following sections detail how these scenarios can be realized. Skip to the examples at the bottom for the concise version.

## Summing all number drop-down fields

This formula returns the sum of the values of all number drop-down fields of a form group:

The formula above can also be written as follows:

However, as the SUM function is looking for an array of numbers to add together, and number drop-down fields return numbers through their Value properties, .Value,Value is inferred and does not need to be spelled out.

In fact, you may be able to make the formula even shorter:

In the formula above, .Items.Value,Items,Value is inferred. In other words, the Items property is accessed, which includes not only fields, but also buttons and text boxes. As buttons and text boxes cannot return numbers, they are ignored by the SUM function, meaning that SUM(FormGroup1)SUM(FormGroup1) returns the sum of all items that can return numbers, including number fields, number drop-down fields and date and time fields.

If you explicitly only want to include the values of number drop-down fields, and not values of number fields and date and time fields, be sure to write SUM(FormGroup1.NumberDropDownFields)SUM(FormGroup1,NumberDropDownFields).

## Summing the other number drop-down fields of a form group

Let's say that the form group *FormGroup1* consists of ten number
drop-down fields, *Field1* through *Field10*. If
*Field10* should contain the sum of the other number drop-down fields,
it is tempting to try to associate this formula with the Value property of
*Field10*:

However, that formula will not work. Instead, you'll get an error message,
because you're effectively asking that the calculated value of
*Field10* includes the value of *Field10* itself.

This is similar to trying to use the formula Field1 * 2Field1 * 2 for the Value
property of *Field1*, effectively asking that the value of
*Field1* should be set to the value of *Field1*, multiplied by
two. This is known as a circular calculation, and results in an error
message.

In order to solve this issue, the formula needs to reference the number drop-down fields to include in the calculation explicitly:

Above, Field1:Field9Field1:Field9 creates an array
consisting of *Field1*, *Field9* and all items that appear
between them. Notably, *Field10* is not part of the array.

## Enabling a button only if all number drop-down fields are valid

The Enabled property of a button
determines if users can interact with the button. If a button should only be
enabled if all number drop-down fields of *FormGroup1* are considered
valid,
associate this formula with the *Enabled* property of the button:

Above, the FormGroup1.NumberDropDownFields.ValidFormGroup1,NumberDropDownFields,Valid formula returns an array of logical values (TRUE or FALSE), where TRUE indicates that a number drop-down field is valid and FALSE indicates that a number drop-down field is invalid. The AND function, when applied to this array, returns TRUE only if all array elements are TRUE. In effect, the button is only enabled if all number drop-down fields of the form group are valid.

## Making the background color red if a number drop-down field is invalid

The BackgroundColor property determines the background color of a screen and all screens that follow that have no explicit background color set. That means that if the background color is set for the first screen of an app, and no other screens have a background color set, the first screen determines the background color of the entire app.

We can make use of this knowledge to make the background of the entire app
red, but only if at least one number drop-down field of the form group
*FormGroup1* is invalid. This formula is associated with the
*BackgroundColor* property of the first screen:

The formula fragment FormGroup1.NumberDropDownFields.ValidFormGroup1,NumberDropDownFields,Valid returns a logical array, where TRUE indicates that the corresponding number drop-down field is valid and FALSE indicates that the corresponding number drop-down field is invalid. Applying the NOT function to this array negates every element, meaning that TRUE indicates that a number drop-down field is invalid and FALSE indicates that a number drop-down field is valid. (The ! operator would have had the same effect.)

Then, the OR function is applied to this array. It returns FALSE only if all elements of the array are FALSE. In other words, it returns TRUE if one or several elements are TRUE, meaning that it returns TRUE if one or several number drop-down fields are invalid.

Finally, the IF
function is used to return the color red if one or several number drop-down
fields are invalid. Otherwise, IF returns a blank value, which has no effect
on the background color. The net effect is that the background color of the
app is made red if one or several number drop-down fields of
*FormGroup1* are invalid.

## Including all number drop-down field values of a form group in an email

The Body property of email report buttons allows the body of an email to be set through a formula. While email report buttons have built-in support for including field values, through the IncludedFields property, building a text string manually to include in the email body allows us more flexibility.

Consider this formula, which should be associated with the *Body*
property of an email report button:

Above, the formula fragment FormGroup1.NumberDropDownFields.LabelFormGroup1,NumberDropDownFields,Label
returns a text array, made up of the labels of the number drop-down
fields of *FormGroup1*. The formula fragment FormGroup1.NumberDropDownFields.ValueFormGroup1,NumberDropDownFields,Value also
returns an array, this time made up of the values of the number
drop-down fields. Using &, the labels are joined
together with the values, separated by a colon.

The resulting text array, where every element consists of a label, followed by a colon and a value, is converted into a single text string using the TEXTJOIN function. Its first parameter, NEWLINE()NEWLINE(), ensures that the array elements are separated from one another using line breaks.

## Requiring all number drop-down fields of a form group to be filled out

The NextScreenAvailable
property of form screens determines if users are allowed to move forward to
the next screen. If a user
should only be allowed to move forward once all number drop-down fields of a
form group have been filled out, associate this formula with the
*NextScreenAvailable* property of the screen that the form group is
part of:

The ISDEFINED function returns a logical array when its sole parameter is an array. TRUE elements in the array indicate that the corresponding number drop-down fields have defined values, that is, have been filled out, and FALSE elements indicate that the corresponding number drop-down fields have not been filled out.

Finally, the AND
function returns TRUE only if all elements of the array are TRUE, otherwise
it returns FALSE. The net effect is that AND returns TRUE only if all number
drop-down fields of *FormGroup1* have been filled out, prompting the
*NextScreenAvailable* property to only allow users to proceed once all
number drop-down fields have defined values.

## Ranges versus this property

If the form group *FormGroup1* only consists of the number drop-down
fields *Field1*, *Field2* and *Field3*, these formulas
are equivalent:

The second formula uses a *range* to create an array consisting of
*Field1*, *Field3* and all items that appear between them,
which in this case is only *Field2*.

The chief advantage of the *NumberDropDownFields* property, compared
to a range, is that there is no need to update formulas when additional
number drop-down fields are added to a form group. If *Field4* were to
be added to the form group, the Field1:Field3Field1:Field3 range would have to be
changed to Field1:Field4Field1:Field4 everywhere it is used.

By contrast, FormGroup1.NumberDropDownFieldsFormGroup1,NumberDropDownFields
automatically includes *Field4*, and any other number drop-down fields
that are added.

## Filtering number drop-down fields

If you want to process only a subset of the number drop-down fields returned from this property, use the FILTER function. It can base its decision on which number drop-down fields to return on the property values of the number drop-down fields.

This formula only returns visible number drop-down fields:

Crucially, you can also filter on the names of the number drop-down fields, using standard text functions. This formula only returns number drop-down fields whose names include the text string "Required":

If you use a deliberate naming strategy for your number drop-down fields, you can use FILTER in conjunction with this property to ensure that you only process a specific subset of number drop-down fields.

## Related properties

Use the NumberDropDownFields property of a screen to access all number drop-down fields of said screen and the NumberDropDownFields property of the app object to access all number drop-down fields of the entire app.

The Fields property returns all fields of a form group, not just number drop-down fields. The Items property returns all items of a form group, including fields, buttons, text boxes and named values. Use NumberFields, TextFields, SwitchFields, DateTimeFields and TextDropDownFields to access other kinds of fields.

## Examples

Returns the sum of the values of all number drop-down fields that belong
to *FormGroup1*.

Returns the sum of the values of all number drop-down fields that belong
to *FormGroup1*. If .Value,Value is left out, it is inferred.

Returns the sum of the values of all number fields and number drop-down
fields that belong to *FormGroup1*.

Returns TRUE if all number drop-down fields of *FormGroup1* are
valid
and FALSE otherwise. FormGroup1.NumberDropDownFields.ValidFormGroup1,NumberDropDownFields,Valid
returns a logical array, where each element reflects whether its
corresponding number drop-down field is valid. Finally, the AND function returns TRUE
if all elements are TRUE and FALSE otherwise.

Returns all number drop-down field values of a form group as a text string, where values are separated from one another using line breaks. The formula fragment FormGroup1.NumberDropDownFields.ValueFormGroup1,NumberDropDownFields,Value returns an array of values, which the TEXTJOIN function joins together with line breaks.

Returns TRUE if all number drop-down fields of *FormGroup1* have
been filled out. When the ISDEFINED function is applied to an
array of number drop-down fields, it returns a logical array whose
elements indicate if the corresponding number drop-down field has a
defined value. The AND function returns TRUE if all array
elements are TRUE and FALSE otherwise.