As a Power Apps developer, you must know about all the Functions in Power Apps. One of the most useful is the **Mod function**.

In this Power Apps tutorial, I will explain the **Power Apps Mod function** and its syntax. Also, we will discuss how to work with Power Apps Mod calculate if number is even or odd; Power Apps Mod Calculate Number of Days from Hours with various use cases.

## Power Apps Mod Function

In Power Apps, the **Mod function** helps return the remainder after a number is divided by a divisor. It is one of the most important and useful functions in Power Apps.

**Syntax of the Power Apps Mod() Function:**

`Mod( Number, Divisor )`

Where,

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

## Power Apps Mod Function Example

Now, I will show you how to work with the Power Apps Mod function using a simple scenario:

**Scenario:**

I have a SharePoint list named “**Employee Onboarding**” and this list contains the below fields.

Column Name | Data Type |

Employee ID | It is a default single line of text |

Name | A single line of text |

A single line of text | |

Gender | Choice |

Joining Date | Date and time |

Department | Lookup |

I want to display these SharePoint list items on the Power Apps Gallery control with an alternative color. That color will depend on whether the number is even or odd.

**Output:**

To work around this, follow the below steps. Such as:

**1.** On the Power Apps Screen -> Insert a **Gallery control** and set its** Items **property to the code below.

`Items = 'Employee Onboarding'`

Where,

**‘Employee Onboarding’**= SharePoint Online list

**2.** Now, set the **TemplateFill** property of the gallery control using the code below.

```
TemplateFill = If(
Mod(
ThisItem.ID,
2
) = 0,
Color.LightBlue,
Color.LightYellow
)
```

Where,

**ThisItem.ID**= SharePoint list ID column**2**= Even number

**3.** Finally, Save, Publish, and Preview the app. The gallery control displays with an alternative color based on the even number, as shown below.

## Power Apps Mod Calculate If Number is Even or Odd

In this example, we will discuss how to calculate whether a number is even or odd using the Power Apps Mod function. To do so, follow the code below.

```
Text = If(
Mod(
8,
2
) = 1,
"Odd Number",
"Even Number"
)
```

Where,

**8**= Even number

In the same way, if you provide an odd number [5] in the Power Apps Mod function, it will return the text value as “Odd Number,” as shown below.

```
If(
Mod(
5,
2
) = 1,
"Odd Number",
"Even Number"
)
```

Where,

**5**= Odd Number

## Power Apps Mod Calculate Number of Days from Hours

Suppose you want to check how many hours an employee worked, and you need to check his overtime to pay him/her. To achieve this, you can use the below formula:

`Mod(12,9) //Mod(<number of hours worked in day>,9)`

Where,

**12**= Number of hours worked in the day**9**= Actual hours in the day

## Power Apps Mod Calculate If Number is Multiple of Another

In this example, I will show you how to check the Power Apps Mod calculate if the number is multiples of another. To do so, follow the code below.

```
Text = If(
Mod(
txt_Number.Value,
5
) <> 0,
"This is Not Multiple",
"This is Multiple"
)
```

Where,

**txt_Number**= Power Apps text input name**5**= To check the multiples of 5

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

## Power Apps Mod Function Limitations

Lastly, we will see the Power Apps Mod function limitations [**You can use only 50 Mod statements, and that is to be 50 nest mod statements**].Refer to the below table:

Suggestions | Determination |

While working with the Power Apps Mod function, follow this recommendation: If the formula contains an error, Power Apps will not return empty or null values instead of any error | As you may know, some of the Power Apps formulas have locality-based differences. Among them, this PowerApps Mod function also has its functionality |

Suppose the formula is Mod(300,0); then, in this case, it will give an error [Invalid operation: division by zero.] | For example, if you 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. |

From this Power Apps tutorial, we learned the Power Apps Mod function and its syntax and how to use the Power Apps Mod function using different real-time scenarios. Such as:

- Power Apps Mod Calculate If Number is Even or Odd
- Power Apps Mod Calculate Number of Days from Hours
- Power Apps Mod Calculate If Number is Multiple of Another

Also, you may like:

- Send Email From Power Apps
- Power Apps Get Office 365 Group Members
- 6 Easiest Ways to Use Power Apps ForAll Function
- Power Apps Toggle Control
- 8 Various Power Apps Sum Column Examples
- Power Apps GroupBy and Ungroup Functions
- Power Apps If Statement Examples

I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com