# GAMMALN Function in Microsoft Excel

**Part 1: Introduction**

### Definition

The GAMMALN function in Excel returns the natural logarithm of the gamma function, Γ(x).

### Purpose

The purpose of the GAMMALN function is to calculate the natural logarithm of the gamma function of a number. It’s often used in mathematics and engineering fields.

### Syntax & Arguments

The syntax for the GAMMALN function is as follows:

`GAMMALN(x) `

In this function, the argument is:

**X**: This is a required argument. It should be the value for which you want to calculate GAMMALN.

### Return Value

The GAMMALN function returns the natural logarithm of the gamma function of the number provided.

### Remarks

If x is non-numeric, GAMMALN returns the `#VALUE!`

error value. If x ≤ 0, GAMMALN returns the `#NUM!`

error value. The number e raised to the GAMMALN(i) power, where i is an integer, produces the same result as (i – 1)!

**Part 2: Examples**

Now, let’s look at some examples of how to use the GAMMALN function in a business context.

### Example 1

**Purpose**: To calculate the GAMMALN of the number of products sold.

A | B | C | |
---|---|---|---|

1 | Products Sold | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.792 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 4.787 |

In this example, we calculate the GAMMALN of the number of products sold. The formula `=GAMMALN(A2)`

calculates the GAMMALN of the number in cell A2.

### Example 2

**Purpose**: To calculate the GAMMALN of the number of clients.

A | B | C | |
---|---|---|---|

1 | Clients | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.792 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 4.787 |

In this example, we’re calculating the GAMMALN of the number of clients. The formula `=GAMMALN(A2)`

calculates the GAMMALN of the number in cell A2.

### Example 3

**Purpose**: To calculate the GAMMALN of the number of orders.

A | B | C | |
---|---|---|---|

1 | Orders | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.792 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 4.787 |

In this example, we’re calculating the GAMMALN of the number of orders. The formula `=GAMMALN(A2)`

calculates the GAMMALN of the number in cell A2.

### Example 4

**Purpose**: To calculate the GAMMALN of the number of units produced.

A | B | C | |
---|---|---|---|

1 | Units Produced | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.792 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 4.787 |

In this example, we’re calculating the GAMMALN of the number of units produced. The formula `=GAMMALN(A2)`

calculates the GAMMALN of the number in cell A2.

### Example 5

**Purpose**: To calculate the GAMMALN of the number of deliveries.

A | B | C | |
---|---|---|---|

1 | Deliveries | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.792 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 4.787 |

In this example, we’re calculating the GAMMALN of the number of deliveries. The formula `=GAMMALN(A2)`

calculates the GAMMALN of the number in cell A2.

### Example 6

**Purpose**: To calculate the GAMMALN of the number of products sold, but only if the number exceeds 2.

A | B | C | D | |
---|---|---|---|---|

1 | Products Sold | Formula | Result | Check |

2 | 4 | =IF(A2>2, GAMMALN(A2), “N/A”) | 1.386 | Pass |

3 | 1.5 | =IF(A3>2, GAMMALN(A3), “N/A”) | N/A | Fail |

4 | 5 | =IF(A4>2, GAMMALN(A4), “N/A”) | 3.178 | Pass |

In this example, we use the IF function to check if the number of products sold exceeds 2. If it is, we calculate the GAMMALN of that number. If it’s not, we return “N/A”.

### Example 7

**Purpose**: To calculate the sum of the GAMMALN values of the number of clients.

A | B | C | |
---|---|---|---|

1 | Clients | Formula | Result |

2 | 4 | =GAMMALN(A2) | 1.386 |

3 | 5 | =GAMMALN(A3) | 3.178 |

4 | 6 | =GAMMALN(A4) | 5.308 |

5 | Sum | =SUM(C2:C4) | 9.872 |

In this example, we’re calculating the GAMMALN of the number of clients and then summing those values using the SUM function.

### Example 8

**Purpose**: To look up the number of orders in a table and calculate the GAMMALN of that number.

Assume we have another table with Order IDs and corresponding Orders:

D | E | |
---|---|---|

1 | Order ID | Orders |

2 | 101 | 4 |

3 | 102 | 5 |

4 | 103 | 6 |

Now, we want to look up the number of orders for a specific Order ID and calculate the GAMMALN of that number:

A | B | C | |
---|---|---|---|

1 | Order ID | Formula | Result |

2 | 101 | =GAMMALN(VLOOKUP(A2, D2:E4, 2, FALSE)) | 1.386 |

3 | 102 | =GAMMALN(VLOOKUP(A3, D2:E4, 2, FALSE)) | 3.178 |

4 | 103 | =GAMMALN(VLOOKUP(A4, D2:E4, 2, FALSE)) | 5.308 |

In this example, we’re using the VLOOKUP function to find the number of orders for a specific Order ID in a separate table (D2:E4), and then we’re calculating the GAMMALN of that number.

### Example 9

**Purpose**: To calculate the GAMMALN of the number of units produced, but only if the number is not an error.

A | B | C | D | |
---|---|---|---|---|

1 | Units Produced | Formula | Result | Check |

2 | 4 | =IF(ISERROR(GAMMALN(A2)), “Error”, GAMMALN(A2)) | 1.386 | Pass |

3 | 0 | =IF(ISERROR(GAMMALN(A3)), “Error”, GAMMALN(A3)) | Error | Fail |

4 | 5 | =IF(ISERROR(GAMMALN(A4)), “Error”, GAMMALN(A4)) | 3.178 | Pass |

In this example, we’re using the ISERROR function to check if the GAMMALN of the number of units produced is an error. If it is, we return “Error”. If it’s not, we calculate the GAMMALN.

### Example 10

**Purpose**: To calculate the GAMMALN of the number of deliveries and round the result to the nearest whole number.

A | B | C | |
---|---|---|---|

1 | Deliveries | Formula | Result |

2 | 4 | =ROUND(GAMMALN(A2), 0) | 1 |

3 | 5 | =ROUND(GAMMALN(A3), 0) | 3 |

4 | 6 | =ROUND(GAMMALN(A4), 0) | 5 |

In this example, we’re calculating the GAMMALN of the number of deliveries and then rounding the result to the nearest whole number using the ROUND function.

### Example 11

**Purpose**: To calculate the GAMMALN of the number of products sold and return the absolute value of the result.

A | B | C | |
---|---|---|---|

1 | Products Sold | Formula | Result |

2 | -4 | =ABS(GAMMALN(A2)) | Error |

3 | -5 | =ABS(GAMMALN(A3)) | Error |

4 | -6 | =ABS(GAMMALN(A4)) | Error |

In this example, we’re calculating the GAMMALN of the number of products sold and then returning the absolute value of the result using the ABS function.

### Example 12

**Purpose**: To calculate the GAMMALN of the number of clients and return the integer part of the result.

A | B | C | |
---|---|---|---|

1 | Clients | Formula | Result |

2 | 4.5 | =INT(GAMMALN(A2)) | 1 |

3 | 5.5 | =INT(GAMMALN(A3)) | 3 |

4 | 6.5 | =INT(GAMMALN(A4)) | 5 |

In this example, we calculate the GAMMALN of the number of clients and then return the integer part of the result using the INT function.

### Example 13

**Purpose**: To calculate the GAMMALN of the number of orders and return the result raised to the power of 2.

A | B | C | |
---|---|---|---|

1 | Orders | Formula | Result |

2 | 4 | =POWER(GAMMALN(A2), 2) | 1.922 |

3 | 5 | =POWER(GAMMALN(A3), 2) | 10.104 |

4 | 6 | =POWER(GAMMALN(A4), 2) | 28.164 |

I hope these examples help clarify the use of the GAMMALN function in Excel.

**Part 3: Tips and Tricks**

- Remember that the GAMMALN function will return an error if the number is non-numeric or less than or equal to 0.
- The GAMMALN function can be used with other functions to perform more complex calculations.
- Always check your data to ensure it’s valid before using the GAMMALN function to avoid errors.