I am calling rest uri from jQuery ajax with filter string comparison startswith as below

/_api/lists/getbytitle('Stations')/items?$select=Id,City_Code,City_Name_EN&$filter=startswith(City_Name_EN,'M') and Active eq 1&$orderby=City_Name_EN asc

Which is working very good. And I am displaying text by programmatically as below

Mumbai(Mum) i.e. City_Name_EN (City_Code)

but is there anyway to filter startwith(City_Name_EN (City_Code),'M') .

I tried to make calculated field in above format. But rest api does not allow to filter calculated field.

Is there any way to filter like that.

  • in my case spaces are separated by x0020 so Serial_x0020_Number in ODATA url works and not %20 or space and comma
    – Iman
    Sep 21, 2015 at 17:44
  • Seems like the filter you gave should already cover what you are trying to do. You are already filtering on the City Name starting with "M". Why do you care what the City Code is? It will give you the same thing. As long as it starts with that city, it doesn't matter if you have City_Name_EN (City_Code) (which is invalid, anyway, because you can only filter on one value at a time) or just City_Name_EN (as you already had) in your filter.
    – vapcguy
    Oct 26, 2021 at 20:59

1 Answer 1


It's not clear exactly what you want to do, but OData $filter has a startswith that you should be able to use here.


See this page: http://msdn.microsoft.com/en-us/library/ff798339.aspx and do a find for "startswith".

When in doubt, check the OData spec. SharePoint implements it for the most part, though there are exceptions, e.g., batching.

  • Thank you for the reply. I am very well aware of startswith operator but my requirement is I want filter two fields as a One string For example, City,City_code which I display like "new york (ny)" and I want filter that
    – Milind
    Sep 29, 2014 at 3:28
  • Can't you just 'and' or 'or' the two conditions, as in this post from Sahil Malik? blah.winsmarts.com/… Sep 29, 2014 at 10:06
  • I could have done with 'or' or 'and' but I am using it in jQuery ui auto-complete
    – Milind
    Sep 29, 2014 at 11:03
  • I don't think you've explained the problem you're trying to solve well then. Are you trying to filter based on a selected value? Sep 29, 2014 at 14:59
  • No I am trying to filter based on selected text not value
    – Milind
    Sep 30, 2014 at 3:10

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.