---
keyword: [Extend, Workday Graph API, Graph API, GraphQL]
nav: wcp_docs
parent_url: /wcp_docs/
title: Sample Query Filters
layout: subsection
---

<a id="section_6"></a>
The examples in this topic use query variables for the `dataSource` and `where` filters. Separating the filter criteria into query variables makes it easier for an app to pass filter criteria values.

## <a id="section_ntd_wv5_stb"></a>Filter Active Workers who are Contingent Workers

This sample query uses a `dataSource` filter and the `where` filter with a criteria field.

```
query getActiveContingentWorkers($dataSourceVariables: Worker_DataSources!, $where: Worker_Criteria) {
  worker(
    dataSource: $dataSourceVariables,
    where: $where
  ) {
    total
    data {
      descriptor
      workerTypes{descriptor}
      supervisoryOrganization_PrimaryPosition{descriptor}
    }
  }
}
```

Sample query variables:

```
{
  "dataSourceVariables": {
    "indexedAllWorkers": {
      "filter": {
        "indexedAllWorkersFilter": {
          "isActive": true
        }
      }
    }
  },
  "where": {
    "workerTypes": {
       "workdayID": {"in": [ {"id": "CW", "type": "Worker_Type_ID"} ]}
    }
  }
}
```

Sample response:

```
{
  "data": {
    "worker": {
      "total": 63,
      "data": [
        {
          "descriptor": "Kelly Crawford [C]",
          "workerTypes": {
            "descriptor": "Contingent Worker"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Recruiting Department"
          }
        },
        {
          "descriptor": "Arvind Meenakshi [C]",
          "workerTypes": {
            "descriptor": "Contingent Worker"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Global Support - Greater India Group"
          }
        },
        . . .
      ]
    }
  }
}
```

## <a id="section_1"></a>Filter Active Workers who are Employees And in the Tax Department

This sample query uses a `dataSource` filter and the `where` filter with multiple criteria fields, which use the implicit AND expression.

```
query getActiveEmployeesInTaxDept($dataSourceVariables: Worker_DataSources!, $where: Worker_Criteria) {
  worker(
    dataSource: $dataSourceVariables,
    where: $where
  ) {
    total
    data {
      descriptor
      workerTypes{descriptor}
      supervisoryOrganization_PrimaryPosition{descriptor}
    }
  }
}
```

Sample query variables:

```
{
  "dataSourceVariables": {
    "indexedAllWorkers": {
      "filter": {
        "indexedAllWorkersFilter": {
          "isActive": true
        }
      }
    }
  },
  "where": {
    "workerTypes": {
       "workdayID": {"in": [ {"id": "EE", "type": "Worker_Type_ID"} ]}
    },
    "supervisoryOrganization_PrimaryPosition": {
       "workdayID": {"in": [ {"id": "SUPERVISORY_Tax_Department", "type": "Organization_Reference_ID"}]}
    }
  }
}
```

Sample response:

```
{
  "data": {
    "worker": {
      "total": 1,
      "data": [
        {
          "descriptor": "Andrew Walton",
          "workerTypes": {
            "descriptor": "Employee"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Tax Department"
          }
        }
      ]
    }
  }
}
```

## <a id="section_2"></a>Filter Active Workers who are Contingent Workers Or Employees in the Tax Department

This sample query uses a `dataSource` filter and the `where` filter with the OR expression and nested AND criteria.

```
query getActiveContingentOrEmployeesInTaxDept($dataSourceVariables: Worker_DataSources!, $where: Worker_Criteria) {
  worker(
    dataSource: $dataSourceVariables,
    where: $where
  ) {
    total
    data {
      descriptor
      workerTypes{descriptor}
      supervisoryOrganization_PrimaryPosition{descriptor}
    }
  }
}
```

Sample query variables:

```
{
  "dataSourceVariables": {
    "indexedAllWorkers": {
      "filter": {
        "indexedAllWorkersFilter": {
          "isActive": true
        }
      }
    }
  },
  "where": {
     "OR": [
        {"workerTypes": {
          "workdayID": {"in": [{"id":"CW","type":"Worker_Type_ID"}]}
         }
        },
        {"AND": [
          {"supervisoryOrganization_PrimaryPosition":{
                "workdayID":{"in":[{"id":"SUPERVISORY_Tax_Department","type":"Organization_Reference_ID"}]}
            }
          },
          {"workerTypes":{
                "workdayID":{"in":[{"id":"EE","type":"Worker_Type_ID"}]}
            }
          }
        ]}
     ]
   }
}
```

Sample response:

```
{
  "data": {
    "worker": {
      "total": 64,
      "data": [
        {
          "descriptor": "Andrew Walton",
          "workerTypes": {
            "descriptor": "Employee"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Tax Department"
          }
        },
        {
          "descriptor": "Kelly Crawford [C]",
          "workerTypes": {
            "descriptor": "Contingent Worker"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Recruiting Department"
          }
        },
        . . .
      ]
    }
  }
}
```

## <a id="section_5"></a>Filter Active Workers who are Not Employees Nor in the Tax Department

This sample query uses a `dataSource` filter and the `where` filter with the NOT expression and nested OR condition.

```
query getActiveNotEmployeesNorInTaxDept($dataSourceVariables: Worker_DataSources!, $where: Worker_Criteria) {
  worker(
    dataSource: $dataSourceVariables,
    where: $where
  ) {
    total
    data {
      descriptor
      workerTypes{descriptor}
      supervisoryOrganization_PrimaryPosition{descriptor}
    }
  }
}
```

Sample query variables:

```
{
  "dataSourceVariables": {
    "indexedAllWorkers": {
      "filter": {
        "indexedAllWorkersFilter": {
          "isActive": true
        }
      }
    }
  },
  "where": {
    "NOT": {
      "OR": [
        {"workerTypes": {
            "workdayID": {"in": [{"id":"EE","type":"Worker_Type_ID"}]}
          }
        },
        {"supervisoryOrganization_PrimaryPosition":{
            "workdayID":{"in":[{"id":"SUPERVISORY_Tax_Department","type":"Organization_Reference_ID"}]}
         }
        }
      ]
    }
  }
}
```

Sample response:

```
{
  "data": {
    "worker": {
      "total": 63,
      "data": [
        {
          "descriptor": "Kelly Crawford [C]",
          "workerTypes": {
            "descriptor": "Contingent Worker"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "Recruiting Department"
          }
        },
        {
          "descriptor": "Chaaya Basu [C]",
          "workerTypes": {
            "descriptor": "Contingent Worker"
          },
          "supervisoryOrganization_PrimaryPosition": {
            "descriptor": "IT HelpDesk Department"
          }
        },
        . . .
      ]
    }
  }
}
```

## <a id="section_3"></a>Filter a Company’s Accounting journals by Date and Status

This sample query uses a `dataSource` filter and the `where` filter with the AND expression. In this example, we use the explicit AND to filter on a date range. Note that an implicit AND doesn't allow repeated criteria fields.

```
query getJournalsByDateAndStatus($dataSourceVariables: Journal_DataSources!, $where: Journal_Criteria){
  journal(
    dataSource: $dataSourceVariables,
    where:$where
  ) {
    total
    data{
      company{descriptor}
      accountingDate
      journalNumber
      descriptor
      journalStatus{descriptor}
    }
  }
}
```

Sample query variables:

```
{
  "dataSourceVariables": {"accountingJournals": {
      "filter":{
        "accountingJournalFilter":{
          "year":{"type":"WID", "id":"d18be16dbe03444996d044de5030cb52"}, 
          "company":{"type":"WID", "id":"cb550da820584750aae8f807882fa79a"}
        }
      }}
    },
  "where": {
      "AND":[
        {"accountingDate":{"gte":"2009-01-01"}}, 
        {"accountingDate":{"lte":"2009-01-31"}}, 
        {"journalStatus": {
          "workdayID":{"notIn":{"type":"Journal_Entry_Status_ID", "id":"Posted"}}}
        }
      ]
    }
}
```

Sample response:

```
{
  "data": {
    "journal": {
      "total": 1,
      "data": [
        {
          "company": {
            "descriptor": "Global Modern Services, Inc. (USA)"
          },
          "accountingDate": "2009-01-31",
          "journalNumber": "4922",
          "descriptor": "4922 - Global Modern Services, Inc. (USA) - 01/31/2009 - Baseline Depreciation",
          "journalStatus": {
            "descriptor": "Unposted"
          }
        }
      ]
    }
  }
}

 
```

## <a id="section_4"></a>Filter Registered Compact Vehicles with multiple conditions

This sample model component query uses the `where` filter with the AND expression and nested conditions.

```
query getCompactVehiclesInSanFrancisco($where: VehicleRegistrationCw_ycjtxv_Vehicle_Criteria){
  vehicleRegistrationCw_ycjtxv_Vehicle(
    dataSource: {vehicleRegistrationCw_ycjtxv_vehicles: {}},
    where: $where
  ) {
    total
    data{
      licensePlate
      location{descriptor}
      compact
      registrationDate
      someDate
      regFee{value}
      make
      model
    }
  }
}
```

Sample query variables:

```
{
  "where": { 
    "AND": [
        { "compact": { "eq": true } },
        {
          "OR": [
            { "location": { "workdayID": {"in": [{"id": "San_Francisco", "type": "Location_ID"}]} } },
            { "registrationDate": {"gte": "2024-01-15"} }
          ]
        },
        {
          "NOT": {"regFee": {"eq": 40}}
        },
        { "someDate": {"empty": true} }
    ]
  }
}
```

Sample response:

```
{
  "data": {
    "vehicleRegistrationCw_ycjtxv_Vehicle": {
      "total": 2,
      "data": [
        {
          "licensePlate": "BEA3832",
          "location": {
            "descriptor": "San_Francisco"
          },
          "compact": true,
          "registrationDate": "2024-01-15",
          "someDate": null,
          "regFee": 25.50,
          "make": "S",
          "model": "Infitini"
        },
        {
          "licensePlate": "DST2345",
          "location": {
            "descriptor": "San_Francisco"
          },
          "compact": true,
          "registrationDate": "2024-01-31",
          "someDate": null,
          "regFee": 30,
          "make": "Subaru",
          "model": "WRZ"
        }
      ]
    }
  }
}
```

### Related Information

[Query Filters](/wcp_docs/GUID-1a496a09-dbf2-4958-9d1f-12bea23b8855-enHYPHENus.html)

