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
Attached Files Details
Extract the files from the attached zip file. Below are details of the files inside the zip file.
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}
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
Hi Solomiia,
Your solution seems to be working.
1 additional clarification on the totals data. If say I have 5 fields that I want to pivot by, either by row or by column, do you mean that I have to calculate totals for the different fields combination?
For example E.g.
1. Total over entire dataset
2. Totals for each unique Field 1 values (example field1=val1, field1=val2, so 2 calculations is required if field 1 have 2 unique members)
3. Totals for each unique Field 2 values
4. Totals for each unique Field 3 values
5. Totals for each unique Field 4 values
6. Totals for each unique Field 5 values
7. Totals for each unique Field 1 + Field 2
8. Totals for each unique Field 1 + Field 2 + Field 3
9. Totals for each unique Field 1 + Field 2 + Field 3 + Field 4
10. Totals for each unique Field 1 + Field 2 + Field 3 + Field 4 + Field 5
11. Totals for each unique Field 1 + Field 3
12. Totals for each unique Field 1 + Field 3 + Field 4
13. Totals for each unique Field 1 + Field 3 + Field 4 + Field 5
14. Totals for each unique Field 1 + Field 3 + Field 5
15. Totals for each unique Field 1 + Field 4
16. Totals for each unique Field 1 + Field 4 + Field 5
17. Totals for each unique Field 1 + Field 5
18. Totals for each unique Field 2 + Field 3
19. Totals for each unique Field 2 + Field 3 + Field 4
…
Is that the case?
Thanks
Jun Jie SOH
Hello, Jun Jie!
Thank you for your question.
Please note that Flexmonster only requests totals and subtotals present in the current view, so there is no need for overcalculation of all combinations on initial load. We suggest relying on the /select request for the fields that should be included in the response.
To have more examples of the server responses in different scenarios, we recommend looking through the requests in the Network tab from this JSFiddle, which is connected to our custom API server. Additionally, you can refer to our GitHub repository, which contains implementations of the custom API server.
The scenario that you have described, when the data for all fields is queried simultaneously, is possible when the expandAll option is set to true. In this case, all the nested fields are expanded immediately upon loading the data, and Flexmonster includes all the available fields in a single request.
E.g. if you have 5 fields, 2 in rows, 2 in columns, and the last one as a measure, with the expandAll set to true, the request would look like this:
{
"aggs": {
"by": {
"cols": [
{ "uniqueName": "operation" },
{ "uniqueName": "operation 1" }
],
"rows": [
{ "uniqueName": "filename" },
{ "uniqueName": "filename 1" }
]
},
"values": [
{ "field": { "uniqueName": "id" }, "func": "sum" }
]
}
}
And the response should contain the separate objects for the each row member & column member intersection that are visible.
For example, this is response object for the cell in the intersection of "value 1" and "test 1":
{
"keys": {
"operation": "execution",
"operation 1": "value 1",
"filename": "test",
"filename 1": "test 1"
}
"values": {
"id": {
"sum": 3535
}
},
}
For the Grand total row, which is the final row in the table, you need to include only the column member key:
{
keys: { "filename 1": 'test 1' },
values: { id: { sum: 3535 } }
},
For the Grand Total value, whose intersection is Grand Total row and Grand Total column, no keys are needed:
{
values: { id: { sum: 3535 } }
},
Hope it helps.
Feel free to ask if there are any further questions.
Kind regards,
Solomiia
Thank you for the clarification. I have verified that this issue is resolved from my side.
Hello, Jun Jie!
Thank you for you rfeedback.
We are happy to hear our answer was helpful.
Do not hesitate to ask if any further questions arise.
Kind regards,
Solomiia
This question is now closed