# How to use Where filter in Xero

To filter data that you fetch from **Xero,** you can use the **Where** parameter:

<figure><img src="https://1055512216-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFxU2LUkJMCfvbE2re5C%2Fuploads%2FMLVsPeVvTNQJmtrpGJz5%2Fimage.png?alt=media&#x26;token=6b6fdd9d-f321-4396-8a9e-cafc8bb2a6d9" alt=""><figcaption></figcaption></figure>

With the **Where** parameter, it's possible to, for example, fetch only Invoices with an amount higher than a certain number, updated after a specific date, etc. To use the **Where** parameter correctly, please check the following materials:

1. [What is the syntax of the Where parameter?](#the-syntax-for-the-where-parameter)
2. [Specific of Where parameter usage for different data types.](#examples-of-where-parameter-usage-for-different-data-types)
3. [List of fields per Xero data entity with their data type.](#list-of-fields-per-xero-data-entity-with-their-data-type-supported-in-where-parameter)

#### The syntax for the Where parameter

The structure for the Where parameter is as follows:

```
<<Name of the data entity parameter>> + <<Operator>> + <<Value to compare with>>
```

The simplest example:

```
Total = 20.00
```

<figure><img src="https://1055512216-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFxU2LUkJMCfvbE2re5C%2Fuploads%2FcUi35fB0VN5QyriKii0b%2Fimage.png?alt=media&#x26;token=89db5ec7-1d5a-44a8-b6e2-6f3526e1e164" alt=""><figcaption></figcaption></figure>

In this example:

* **Total** - the name of the data entity field
* **=** - operator
* &#x20;**20.00** - value to compare with

Available **operators** for each data type are different:

| **Data type**                                                       | **Allowed operators**                                                                  |
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| String                                                              | <p>==</p><p>.Contains("value")</p><p>.StartsWith("value")</p><p>.EndsWith("value")</p> |
| GUID                                                                | =GUID("value")                                                                         |
| Number                                                              | =, >, <, >=, <=, !=                                                                    |
| Date                                                                | =, >, <, >=, <=, !=                                                                    |
| Boolean                                                             | ==                                                                                     |
| <p>Data with predefined</p><p>set of values (i.e. Type, Status)</p> | <p>==</p><p>!=</p>                                                                     |

**It is possible to use several conditions in the Where parameter:**

To fetch results that correspond to both conditions - use AND / &&:

```
Type=="ACCPAY" && AmountDue > 0
```

To fetch results that correspond to one of the conditions - use OR /  ||:

```
TaxType == "TAX001" OR TaxType == "TAX002"
Type == "ACCPAY" || Type == "ACCREC"
```

#### Examples of Where parameter usage for different data types

Parameters with  **GUID** type:

```
AccountID = GUID("CEEF66A5-A545-413B-9312-78A545AADBC4")
```

Parameters with **String** type.

It is possible to filter data by **exact value**, data that **contains** some value, data **starts** from some value, data **ends** with some value:

```
Name=="Checking Account"
Name.Contains("Account")
Name.StartsWith("Account")
Name.EndsWith("Account")
```

**Note**: Check for not null value can be required for optional String parameters - i.e. *BankAccountNumber*

```
BankAccountNumber=="132435465"
BankAccountNumber != null AND BankAccountNumber.Contains("132435465")
BankAccountNumber != null AND BankAccountNumber.StartsWith("1")
BankAccountNumber != null AND BankAccountNumber.EndsWith("1")
```

Parameters with **Number** type.

It is possible to filter data if it **equals** some value, **less**, **more**, **less\&equals,** **more\&equals** or not **equals**:

```
Total = 20.00
Total < 20.00
Total > 20.00
Total <= 20.00
Total >= 20.00
Total != 20.00
```

Parameters with a  **Date** type.

It is possible to filter data using dates and next comparison: **equal**, **before**/**after** (including or excluding the date), **not equal**:

```
Date = DateTime(2022, 01, 30)
Date > DateTime(2022, 01, 01)
Date >= DateTime(2022, 01, 01)
Date < DateTime(2022, 01, 01)
Date <= DateTime(2022, 01, 01)
Date != DateTime(2022, 01, 01)
```

Parameters with  **Boolean** type:

```
ShowInExpenseClaims == TRUE
EnablePaymentsToAccount == FALSE
```

Parameters with types that have a  **predefined set of values** (i.e. Account Type, Account Status, Tax Type):

```
TaxType == "TAX001"
Type != "SPEND"
```

#### List of fields per Xero data entity with their data type (supported in Where parameter)

#### Accounts

It is possible to use the next parameters in the  **Where** field:

| **Parameters**                                                                                              | **Type**                                                                                       |
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| AccountID                                                                                                   | GUID                                                                                           |
| <p>Code, Name, BankAccountNumber</p><p>Description, CurrencyCode, ReportingCode</p><p>ReportingCodeName</p> | String                                                                                         |
| Type                                                                                                        | [Account Type](https://developer.xero.com/documentation/api/accounting/types/#accounts)        |
| Status                                                                                                      | [Account Status](https://developer.xero.com/documentation/api/accounting/types/#accounts)      |
| BankAccountType                                                                                             | [Bank Account type](https://developer.xero.com/documentation/api/accounting/types/#accounts)   |
| TaxType                                                                                                     | [Tax Type](https://developer.xero.com/documentation/api/accounting/types/#tax-rates)           |
| <p>EnablePaymentsToAccount</p><p>ShowInExpenseClaims</p><p>HasAttachments</p><p>AddToWatchlist</p>          | Boolean                                                                                        |
| Class                                                                                                       | [Account Class Types](https://developer.xero.com/documentation/api/accounting/types/#accounts) |
| UpdatedDateUTC                                                                                              | Date                                                                                           |

#### Bank Transactions

It is possible to use the next parameters in the  **Where** field:

| **Parameters**                                                                                                      | **Type**                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| <p>BankTransactionID</p><p>PrepaymentID</p><p>OverpaymentID</p><p>BankAccount.AccountID</p><p>Contact.ContactID</p> | GUID                                                                                                             |
| Type                                                                                                                | [Bank Transaction Type](https://developer.xero.com/documentation/api/accounting/types/#bank-transactions)        |
| <p>IsReconciled</p><p>HasAttachments</p>                                                                            | Boolean                                                                                                          |
| DateString                                                                                                          | Date                                                                                                             |
| <p>CurrencyCode</p><p>CurrencyRate</p><p>Url</p><p>BankAccount.Code</p><p>BankAccount.Name</p><p>Contact.Name</p>   | String                                                                                                           |
| Status                                                                                                              | [Bank Transaction Status Code](https://developer.xero.com/documentation/api/accounting/types/#bank-transactions) |
| LineAmountTypes                                                                                                     | [Line Amount Type](https://developer.xero.com/documentation/api/accounting/types/#invoices)                      |
| SubTotal, TotalTax, Total                                                                                           | Number                                                                                                           |
| <p><br></p>                                                                                                         | <p><br></p>                                                                                                      |

#### Bank Transfers

Xero API allows filtering of Bank Transfers by any parameter. See [Bank Transfer](https://developer.xero.com/documentation/api/accounting/banktransfers#get-banktransfers) Xero documentation.&#x20;

#### Branding Themes

The **Where** parameter is not supported.

#### Contact Groups

Xero API allows filtering of Contact Groups by any parameter. See [Contact Groups](https://developer.xero.com/documentation/api/accounting/contactgroups) Xero documentation.&#x20;

#### Contacts

Xero documentation recommends **limiting** filtering to **optimized** parameters only:

| **Parameters**                                     | **Type** |
| -------------------------------------------------- | -------- |
| ContactID                                          | GUID     |
| <p>ContactNumber</p><p>Name</p><p>EmailAddress</p> | String   |

#### Credit Notes

Xero API allows the filtering of Credit Notes by any parameter. See [Credit Notes](https://developer.xero.com/documentation/api/accounting/creditnotes#get-creditnotes) Xero documentation.&#x20;

#### Currencies

Xero API allows the filtering of Currencies by any parameter. See [Currencies ](https://developer.xero.com/documentation/api/accounting/currencies)Xero documentation.&#x20;

#### Employees

Xero API allows the filtering of Employees by any parameter. See [Employees ](https://developer.xero.com/documentation/api/accounting/employees)Xero documentation.&#x20;

#### Expense Claims

Xero API allows filtering of Expense Claims by any parameter. See [Expense Claims](https://developer.xero.com/documentation/api/accounting/expenseclaims#overview) Xero documentation.&#x20;

#### Invoices

Xero documentation recommends limiting  filtering to **optimized** parameters only:

| **Parameters**                           | **Type**                                                                                                     |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| <p>InvoiceID</p><p>Contact.ContactID</p> | GUID                                                                                                         |
| InvoiceNumber                            | Number                                                                                                       |
| Status                                   | [Invoice Status Code](https://developer.xero.com/documentation/api/accounting/invoices#invoice-status-codes) |
| <p>Contact.Name</p><p>Reference</p>      | String                                                                                                       |
| Date                                     | Date                                                                                                         |
| Type                                     | [Invoice Type](https://developer.xero.com/documentation/api/accounting/types#invoices)                       |

#### Items

Xero API allows the filtering of Items by any parameter. See [Items ](https://developer.xero.com/documentation/api/accounting/items#get-items)Xero documentation.&#x20;

#### Journals

Journals Data Entity has no "Where" parameter in settings. However, it has 2 specific fields that allow fetching journals filtered by JournalNumber:

* *Journal number more than*
* *Journal number less than*

#### Linked Transactions

The  **Where** parameter is not supported.

#### Manual Journals

Xero API allows the filtering of Manual Journals by any parameter. See [Manual Journals](https://developer.xero.com/documentation/api/accounting/manualjournals#overview) Xero documentation.&#x20;

#### Organisation

The  **Where** parameter is not supported.

#### Overpayments

Xero API allows the filtering of Overpayments by any parameter. See [Overpayments ](https://developer.xero.com/documentation/api/accounting/overpayments#get-overpayments)Xero documentation.&#x20;

#### Payments

Xero API allows the filtering of Payments by any parameter, but defines a list of optimized parameters:

| **Parameters**                           | **Type**                                                                                     |
| ---------------------------------------- | -------------------------------------------------------------------------------------------- |
| <p>PaymentId</p><p>Invoice.InvoiceId</p> | GUID                                                                                         |
| PaymentType                              | [Payment Type](https://developer.xero.com/documentation/api/accounting/types#PaymentTypes)   |
| Status                                   | [Status](https://developer.xero.com/documentation/api/accounting/types#payment-status-codes) |
| Date                                     | Date                                                                                         |
| Reference                                | String                                                                                       |

#### Prepayments

Xero API allows filtering of Prepayments by any parameter. See [Prepayments ](https://developer.xero.com/documentation/api/accounting/prepayments#get-prepayments)Xero documentation.&#x20;

#### Purchase Orders

*The **Where** parameter is not supported.*

#### Receipts

Xero API allows the filtering of Receipts by any parameter. See [Receipts ](https://developer.xero.com/documentation/api/accounting/receipts#get-receipts)Xero documentation.&#x20;

#### Repeating Invoices

Xero API allows the filtering of Repeating Invoices by any parameter. See [Repeating Invoices](https://developer.xero.com/documentation/api/accounting/repeatinginvoices#get-repeatinginvoices) Xero documentation.&#x20;

#### Tax Rates

Xero API allows the filtering of Tax Rates by any parameter. See [Tax Rates](https://developer.xero.com/documentation/api/accounting/taxrates#get-taxrates) Xero documentation.&#x20;

#### Tracking Categories

Xero API allows the filtering of Tracking Categories by any parameter. See [Tracking Categories](https://developer.xero.com/documentation/api/accounting/trackingcategories#overview) Xero documentation.&#x20;

#### Users

| **Parameters**                                     | **Type**                                                                              |
| -------------------------------------------------- | ------------------------------------------------------------------------------------- |
| UserID                                             | GUID                                                                                  |
| <p>EmailAddress</p><p>FirstName</p><p>LastName</p> | String                                                                                |
| IsSubscriber                                       | Boolean                                                                               |
| OrganisationRole                                   | [User role](https://developer.xero.com/documentation/api/accounting/types#user-roles) |
| UpdatedDateUTC                                     | Date                                                                                  |

> ***If you can't find the case that you need or have any issues with syntax, please write to our support team!***
>
> *If you find discrapency in the documentation, please reach out to our support team as well - we'll quickly update it.*
>
> *Meantime, check* [*Xero documentation*](https://developer.xero.com/documentation/api/accounting/accounts#get-accounts) *for the latest information.*
