# PowerApps Mod Function

Do you know what is the Mod function in PowerApps and how it works in many different cases? Look at this PowerApps tutorial that will help you to understand properly.

Here we will cover the below Mod function related things:

• PowerApps Mod Function
• PowerApps Mod Function Syntax
• PowerApps Mod Function Limitations
• Suggestions or recommendations of PowerApps Mod Function
• PowerApps Mod Determinations
• PowerApps Mod Function Example
• PowerApps Mod calculate if a number is even or odd
• PowerApps Mod calculate the number of days from hours
• PowerApps Mod calculate if a number is a multiple of another

## PowerApps Mod Function

PowerApps Mod function is a type of function that helps to return the remainder after a number is divided by a divisor. Also, this is one of the most important and useful functions in PowerApps.

To get some related info, read this PowerApps tutorial: Power Apps Calculate + 13 Examples

## PowerApps Mod Function Syntax

The below code represents the syntax of the PowerApps Mod function.

``Mod( Number, Divisor )``

Where,

1. Number = This is required. Here you need to specify a number to divide.
2. Divisor = This is required. Here you need to specify a number to divide by.

## Limitations in PowerApps Mod Function

In PowerApps, you can use only 50 Mod statements and that is to be 50 nest mod statements.

### Suggestions

• There is a recommendation while you are working with the PowerApps Mod function. If there is an error in the formula, then the Powerapps will not return empty or null values instead of any error.
• Suppose the formula is Mod(300,0), then, in this case, the user will not get any error even it’s mathematically incorrect. So you need to ensure that what the Mod parameter is expecting in the formula.

### Determination

• As you may know, some of the PowerApps formulas have locality-based differences. Among them, this PowerApps Mod function also has its functionality.
• For example, If you will write the code as Mod(20,5), then it should separate each of the arguments with a comma (,). But if your localization is something else like France, then you need to use a semicolon (;) instead.

Do you know what is PowerApps Collection and how to use it? Check out this PowerApps tutorial to understand it properly: Create Collection from SharePoint List in PowerApps

## PowerApps Mod Function Example

Let’s take a simple useful scenario where we can use the Mod function in PowerApps.

• In the below screen, you can see there is a Browse Gallery Control where all the items are retrieved from a Sharepoint list.
• Now I would like to view the browse gallery rows with an alternative color. And that color will depend upon a number is even or odd.
• To achieve this things in the PowerApps Browse Gallery, we will use a property called TemplateFill. This property helps to set the background of each row in the gallery control.
• Select the gallery control and apply the below code on its TemplateFill property as:
``````TemplateFill = If(
Mod(
ThisItem.ID,
3
) = 0,
LightCyan,
BurlyWood
)``````
• The above code specifies if the item ID is divided by with a number 3 and then if the reminder comes 0, then all the even rows will appear with LightCyan otherwise the rows will appear with BurlyWood color as shown in the above figure.

This is how to use Mod Function in PowerApps.

## PowerApps Mod calculate if a number is even or odd

As in the above scenario, we already discussed how to calculate if a number is even or odd by using the PowerApps Mod function.

• As we know, there is no such function in PowerApps that can use to check the even or odd number directly. But alternatively, here we can use the PowerApps Mod function to achieve our needs.
• Below represents the formula that you can try out:
``````If(Mod(number,2)=1,"Odd Number","Even Number")
``````

By using the above code, we can display the items in a different color by defining the one for the Odd numbers and another for the Even numbers.

## PowerApps Mod calculate the number of days from hours

• Do you want to check how many hours a doctor worked and you need to check his overtime to pay him? To achieve this, you can use the below formula:
``````Mod(<number of hours worked per day>,9) .
``````

Here you just get the total number of hours from the sheet but to calculate the overtime you need to get the remainder of the division by 9 hours (the overtime).

## PowerApps Mod calculate if a number is a multiple of another

In this scenario, We will check if a number is a multiple of another or not.

• In the below screenshot, there is a Text input control and label control. Select the label control and apply the below formula on its Text property as:
``````Text = If(
Mod(
TextInput1.Text,
5
) <> 0,
"This is Not Multiple",
"This is Multiple"
)``````

Where,

TextInput1 = Specify the text input control name where a user will enter a number

This is how to check if a number is a multiple of another using the PowerApps Mod function.

Also, you may like the below PowerApps Tutorials:

In this PowerApps tutorial, we discussed the Mod function in Power Apps. Also, by taking some scenarios, we got to know how we can use the PowerApps Mod function.

Also, we covered these below related Mod function topics:

• PowerApps Mod Function
• PowerApps Mod Function Syntax
• PowerApps Mod Function Limitations
• Suggestions or recommendations of PowerApps Mod Function
• PowerApps Mod Determinations
• PowerApps Mod Function Example
• PowerApps Mod calculate if a number is even or odd
• PowerApps Mod calculate the number of days from hours
• PowerApps Mod calculate if a number is a multiple of another