I have two filters to filter on ,one is status and other is category.

  1. status is : new/approve/rejected and blank

if status is new then show new records , if approve then approved, if set blank then show all but rejected

  1. category can be blank or something if no category is set (means) blank then it should all the records ,if set then only those records.

i have written following query but iam not getting how to set for blank values which can display all records regardless of category set.

https://mysiteoffice365.sharepoint.com/_api//web/Lists/GetByTitle('listName')/items?$select=id,Title,category,status&$filter=((status eq 'new') and (category eq '')) 
  • Have you tried null instead of single quotes?
    – Mike
    Feb 5, 2016 at 14:01
  • what is the relationship betwn status & category? it is and or or? Feb 8, 2016 at 11:37
  • i have added "and" but according to conditions iam but unsure because if status is new and category is empty it wont show any results .... soo condition which i have to fullfil is category can be blank or something if no category is set (means) blank then it should all the records
    – meer
    Feb 8, 2016 at 12:21

2 Answers 2


You can apply some conditional filtering like following:

var filter = "";

if (statusFilter) {
    filter += "status eq '" + statusFilter + "'";

if (!statusFilter) {
    filter += "status ne 'Rejected'";

if (categoryFilter) {
    filter += "and category eq '" + categoryFilter + "'";

The following solution worked for me.

Comparing the column to and empty value you should use 'gt' (greater than), no 'eq' (equals). In string comparison it counts number of characters and uses them in comparison. As null reference you can use '' (empty quotes) or 0 (zero).

In your example it would look like:

https://mysiteoffice365.sharepoint.com/_api//web/Lists/GetByTitle('listName')/items?$select=id,Title,category,status&$filter=((status eq 'new') and (category gt '')) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.