Skip to Content
avatar image
Former Member

AVG function in .xsodata file

Hi,

How can I force the oData (Hana XS .xsodata) AVG function to return an Integer, and not a Decimal?

Is it feasible to round it off (in the service itself)?

Thank you.

Fernando

Add comment
10|10000 characters needed characters exceeded

  • Can you add some more details how you realized the AVG function, cause the OData v2 Standard which is used for xsodata does not support an average function. Is the base for your service a calc. view which you have integrated the aggregated always addition?

  • Get RSS Feed

2 Answers

  • Mar 27, 2017 at 05:44 PM

    Hello Fernando,

    As Florian mentioned, if the AVG calculation is on your base view, please check if it is defined as an integer in your base view. IF you look at the $metadata of the oData you should see type "Edm.Int32" for the average field. Something like this....

    <Key> <PropertyRef Name="FILED1"/> </Key>

    <Property Name="FIELD1" Type="Edm.Int32"/>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 05, 2017 at 03:54 PM

    Thanks for the answers, I ended up solving this by casting to Integer in the view itself (where the oData is built on top of).

    It seems that the AVG oData function keeps the original input data type, i.e. if you provided a float, it will return an AVG float, which was the case. This is good!

    Add comment
    10|10000 characters needed characters exceeded