how to skip null values in odata response?

Mohamed Ali JAMAOUI picture Mohamed Ali JAMAOUI · Oct 15, 2013 · Viewed 25.3k times · Source

I have an odata web service that is returning some null values. I would like to skip these null values. I tried to use the Ne(Not equal) operator to filter the data with null values:

analyticView.xsodata/analyticView?$select=QUANTITY_SOLD,SALE_PRICE&$filter=SALE_PRICE+Ne+null)&$format=json

and I am getting the following error message:

"Illegal operation 'Ne' at position 11."

I tried also to combine the Not operator with the eq operator in this way:

analyticView.xsodata/analyticView?$select=QUANTITY_SOLD,SALE_PRICE&$filter=not(SALE_PRICE+eq+null)&$format=json

I keep getting an error message saying:

value: "No property 'null' exists in type ...

I am using SAP HANA analytic view as a data source, but I thing the issue is not vendor dependent. so, what to do to skip the null values?

Answer

Mohamed Ali JAMAOUI picture Mohamed Ali JAMAOUI · Oct 16, 2013

The above solutions should work fine, baring in mind that the operators are case sensitive as pointed out by Tne. So in general to filter null values you can use:

  • $filter=(SALE_PRICE+ne+null)
  • or $filter=not(SALE_PRICE+eq+null)

However in the particular case of SAP HANA analytic views the null value is not supported, as a workaround the filters can be defined on the table column at the modeling level of the analytic view. The solution is explained here.