dosubot[bot] commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-2658808150
<!-- Greeting -->
Hey @Kuaffu! I'm here to help you with any bugs, questions, or contributions
you have for Superset. Let's work together to solve this issue!
<!-- Answer -->
To address the issue of incorrect subtotal and sum calculation of completion
percentage in a pivot table, you can use the "Sum over Sum" aggregator
template. This aggregator calculates the ratio of the sum of two fields, which
is what you need for calculating "sum(actual_amount) / sum(target_amount)".
Here's how you can implement it:
```js
const { sumOverSum } = aggregatorTemplates;
// Use the sumOverSum aggregator with the actual_amount and target_amount
fields
const completionPercentageAggregator = sumOverSum(['actual_amount',
'target_amount']);
```
This approach ensures that the completion percentage is calculated as the
sum of actual amounts divided by the sum of target amounts, rather than summing
the individual completion percentages
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.js)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=hallucination)
| [Bug
Report](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/5eb2b889-bc49-4072-bc1b-028ca53f7487?feedback_type=other)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]