Skip to Content
0

AVG function in .xsodata file

Mar 27, 2017 at 03:48 PM

157

avatar image
Former Member

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

10 |10000 characters needed characters left 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?

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Mar 27, 2017 at 05:44 PM
0

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"/>

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member
Apr 05, 2017 at 03:54 PM
0

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!

Share
10 |10000 characters needed characters left characters exceeded