# FirstOrDefault

### **Description**‌

The FirstOrDefault function returns the first record in the table. If the table is empty, `defaultValue` is returned instead.

### **Syntax**

‌The syntax for the FirstOrDefault function is:

`FirstOrDefault(table, defaultValue)`

#### ‌**Parameters**

table - the table with the data from which the first row is to be taken.

defaultValue - the record values returned if the table is empty.

### **Returns**

‌The FirstOrDefault function returns a record.

### **Applies To**‌

Flow 6‌.13

### **Example**‌

Let's look at some FirstOrDefault function examples and explore how to use the FirstOrDefault function.‌

<div align="left"><img src="https://529897662-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-MZmc2hwNmUAnYJ4xByD%2F-MZqLDM_GZhrbVH2wLFi%2Fcolors.jpg?alt=media&#x26;token=6c6e94b4-4c75-454c-94b6-3f5a93d0e473" alt="Example table: colors"></div>

<div align="left"><img src="https://529897662-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtPTgZOYmpJka4jqs1v%2F-MZrCcMcEFPyLFlNCr1x%2F-MZrCuuNCQLaxRkNi5aH%2Fempty.jpg?alt=media&#x26;token=9f2940c8-6e8b-44b6-ad18-07d13212b27f" alt="Example table2: emptyTable"></div>

```
FirstOrDefault(color, [Id:'C5', Color:'pink'])
Result: Id: C1, Color: red - as Record

FirstOrDefault(emptyTable, [Id:'C5', Color:'pink'])
Result: Id: C5, Color: pink - as Record

FirstOrDefault( table(a, b), [a: 0, b: 0])
Result: [a: 0, b: 0] - as Record
```
