Amazon QuickSight – Mod
The MOD function in Amazon QuickSight returns the remainder after dividing the number parameter by the divisor parameter.
Syntax
#Start# MOD(number, divisor) #End#
This function takes two arguments:
- number: (required) the number to be divided.
- divisor: (required) the number to divide number by.
Suppose you have a dataset containing a list of orders with the total cost of each order, and you want to calculate the remainder of each order’s total cost after dividing it by 5. You can use the MOD function to accomplish this.
Assume the following dataset:
| Order ID | Total Cost |
| 1 | 10 |
| 2 | 25 |
| 3 | 17 |
| 4 | 32 |
| 5 | 15 |
To calculate the remainder after dividing the total cost by 5, you can create a calculated field using the MOD function:
Example
#Start# MOD({Total Cost}, 5) #End#
This will result in a new column showing the remainder of each order’s total cost after dividing it by 5:
| Order ID | Total Cost | MOD(Total Cost, 5) |
| 1 | 10 | 0 |
| 2 | 25 | 0 |
| 3 | 17 | 2 |
| 4 | 32 | 2 |
| 5 | 15 | 0 |
In this example, the MOD function returns a value of 0 for orders 1, 2, and 5 because the total cost of those orders is evenly divisible by 5. For orders 3 and 4, the remainder after dividing the total cost by 5 is 2.