Aggregation by fields is not working for custom data server api approach

Answered
Jun Jie asked 2 days ago

Issue Description

When attempting data pivot with classic layout using custom data server api approach, the pivot chart aggregation is failing for "Sum of id". However, aggregation is working when Calculated Formula "FormulaSumId", which does sum("id"), is used instead.

Version Details

  • ngx-flexmonster: 2.9.124
  • @angular/cli: ^18.2.12
  • Node Version: 20.11.1

Attached Files Details

Extract the files from the attached zip file. Below are details of the files inside the zip file.

  • json fm aggregate by sum id.json
    • Json settings of pivot view for Sum aggregated Id field
  • json fm aggregate by sum id using formula.json
    • Json settings of pivot view using calculated formula FormulaSumId
  • fields fm aggregate by sum id.png
    • Image of field setting of pivot view for Sum aggregated Id field
  • fields fm aggregate by sum id using formula.png
    • Image of field setting of pivot view using calculated formula FormulaSumId
  •  result fm aggregate by sum id.png
    • Final resulting pivot for aggregate by sum id after applying the fields setting 
  • result fm aggregate by sum id using formula.png
    • Final resulting pivot using calculated formula FormulaSumId after applying the fields setting

Data Server API (Example used)

api1: https://localhost:8080/flexmonster/data-server/handshake

api1 req: { "type": "handshake", "version": "2.9.124" }

api2 res: {"version":"2.9.124"}

api2: https://localhost:8080/flexmonster/data-server/fields

api2 req: { "index": "1712145", "type": "fields" }

api2 res: {"fields":[{"uniqueName":"filename","type":"string","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null},{"uniqueName":"id","type":"number","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null},{"uniqueName":"tablename","type":"string","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null},{"uniqueName":"operation","type":"string","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null},{"uniqueName":"command","type":"string","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null},{"uniqueName":"who","type":"string","caption":null,"hierarchy":null,"parent":null,"folder":null,"interval":null,"aggregations":[],"filters":null}],"aggregations":{"any":null,"date":["count","distinctcount"],"number":["sum","count","distinctcount","average","min","max"],"string":["count","distinctcount"]},"filters":true,"sorted":false}

api3: https://localhost:8080/flexmonster/data-server/members

api3 req: {"index":"1712145","type":"members","field":{"uniqueName":"operation"},"page":0}

api3 res: {"members":[{"id":"execution","value":"execution"},{"id":"file ops","value":"file ops"},{"id":"test console","value":"test console"}],"sorted":true,"pageTotal":1,"page":0,"nextPageToken":null}

api4: https://localhost:8080/flexmonster/data-server/members

api4 req: {"index":"1712145","type":"members","field":{"uniqueName":"filename"},"page":0}

api4 res: {"members":[{"id":"run","value":"run"},{"id":"test","value":"test"},{"id":"test 1","value":"test 1"},{"id":"test 2","value":"test 2"}],"sorted":true,"pageTotal":1,"page":0,"nextPageToken":null}

api5: https://localhost:8080/flexmonster/data-server/select

api5 req: {"type":"select","index":"1712145","query":{"aggs":{"by":{"rows":[{"uniqueName":"operation"}],"cols":[{"uniqueName":"filename"}]},"values":[{"func":"sum","field":{"uniqueName":"id"}}]}},"querytype":"select","page":0}

api5 res: {"fields":null,"hits":null,"aggs":[{"keys":{"filename":"test","operation":"file ops"},"values":{"id":{"sum":245}}},{"keys":{"filename":"test 1","operation":"test console"},"values":{"id":{"sum":235}}},{"keys":{"filename":"run","operation":"execution"},"values":{"id":{"sum":375}}},{"keys":{"filename":"test 1","operation":"file ops"},"values":{"id":{"sum":121}}},{"keys":{"filename":"test 2","operation":"test console"},"values":{"id":{"sum":239}}}],"pageTotal":1,"page":0,"nextPageToken":null}

 

 

1 answer

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster 5 hours ago

Hello, Jun Jie!

Thank you for reaching out to us and for the detailed description of your use case.

Kindly note that Flexmonster expects to receive the totals data in /select response, even with the showTotals: off option enabled.

We have modified the provided /select response and included missing keys: https://jsfiddle.net/flexmonster/p9306qtf/.

Hope you will find our answer helpful.
Feel free to reach out to us in case of any other questions.

Kind regards,
Solomiia

Please sign in or register to submit your answer