You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Kuaffu (via GitHub)" <gi...@apache.org> on 2025/02/14 10:01:27 UTC
[I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Kuaffu opened a new issue, #32260:
URL: https://github.com/apache/superset/issues/32260
### Bug description
we created a pivot table chart to show the completion percentage of sales area, and enabled the subtotal and sum function, the target and actual amount is correct, but the subtotal and sum of completion is wrong, what I'd like to get is " sum(actual_amount) / sum(target_amount)", however, the pivot table sum the completion percentage. anybody met this issue?

### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
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: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-4232931002
@dosu aren't there a whole bunch of open issues about the subtotals/sums in pivot tables open already? Can. you try to find and list them all here, and maybe suggest a "main" thread that we can consolidate thoughts/conversation/approaches around?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "Kuaffu (via GitHub)" <gi...@apache.org>.
Kuaffu commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-2756184430
@ng22t7a Sorry for not resolving this issue. I'm not particularly familiar with Superset, but I've seen similar situations in other BI tools. When it comes to totals or subtotals involving calculated fields, it often requires generating additional SQL queries to handle the computation.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "nyatitilkesh (via GitHub)" <gi...@apache.org>.
nyatitilkesh commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-3095680372
Has anyone been able to find a solution to this issue?
I'm specifically trying to identify where in the code the percentage values are being summed up incorrectly in the pivot table. Any pointers on which file or function handles subtotal calculations for percentage fields would be really helpful. Thanks!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-3495222467
> Compared to superset, excel allows users to insert a function inside the grid to calculate the answers. Do you think superset needs such a tool? @rusackas
It could be very cool! I men, we don't want to head down the road of becoming Excel, but I can see the utility, as long as it's "safe" (i.e. we're not allowing arbitrary JS, but perhaps something more like Jinja, some exposed utility methods, Handlebars helpers, etc.). Definitely open to proposals!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "Kuaffu (via GitHub)" <gi...@apache.org>.
Kuaffu closed issue #32260: Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table
URL: https://github.com/apache/superset/issues/32260
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #32260: Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table
URL: https://github.com/apache/superset/issues/32260
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-4232951807
<!-- Answer -->
Yes — there are quite a few! Here's what I found across open issues, discussions, and proposals all related to incorrect subtotal/total calculations in pivot tables and table charts:
**Open Bug Reports:**
- [**#38674**](https://github.com/apache/superset/issues/38674) — Grand Total sums percentages instead of re-calculating the metric [[1]](https://github.com/apache/superset/issues/38674)
- **#32260** (this issue) — Subtotal/sum of completion percentage is wrong in pivot tables
- [**#36165**](https://github.com/apache/superset/issues/36165) — Table visual summary value not matching for COUNT_DISTINCT [[2]](https://github.com/apache/superset/issues/36165)
- [**#39223**](https://github.com/apache/superset/issues/39223) — DISTINCT_AVG / DISTINCT_SUM broken in v6 (regression) [[3]](https://github.com/apache/superset/issues/39223)
- **#25747** — Referenced as the original issue that PR #34592 targets
**Open Feature Requests / Proposals:**
- [**#38586**](https://github.com/apache/superset/issues/38586) — [SIP-205] Proposal for AntV S2-based Pivot Table, which identifies incorrect aggregation as a core motivation [[4]](https://github.com/apache/superset/issues/38586)
- [**#38036**](https://github.com/apache/superset/discussions/38036) — Per-metric aggregation function in Pivot Table V2 [[5]](https://github.com/apache/superset/discussions/38036)
- **#34245** — [SIP-179] Enhanced aggregation customization in totals/subtotals [[6]](https://github.com/apache/superset/issues/34245)
- [**#35089**](https://github.com/apache/superset/issues/35089) — Rename "Subtotal" to "Subvalue" (misleading labels for non-sum aggregations) [[7]](https://github.com/apache/superset/issues/35089#issuecomment-4156939275)
**Closed (as duplicates / insufficient info, not actually fixed):**
- [**#34350**](https://github.com/apache/superset/issues/34350), [**#34425**](https://github.com/apache/superset/issues/34425), [**#34426**](https://github.com/apache/superset/issues/34426) — Percentage calculation issues in tables with pagination [[8]](https://github.com/apache/superset/issues/34350#issuecomment-3126342060) [[9]](https://github.com/apache/superset/issues/34425)
**Architectural Discussion:**
- [**#29297**](https://github.com/apache/superset/discussions/29297) — Totals in Table Charts (comprehensive discussion of the root cause) [[10]](https://github.com/apache/superset/discussions/29297)
**Related PR (open, unmerged for ~9 months):**
- [**PR #34592**](https://github.com/apache/superset/pull/34592) — "fix(pivot-table): Correct totals for non-additive metrics" — proposes a multi-query architecture [[11]](https://github.com/apache/superset/pull/34592)
***
**Suggested "main" thread for consolidation:** I'd recommend **[#38674](https://github.com/apache/superset/issues/38674)** as the primary consolidation point. It's the most recent and well-described bug report, already cross-references #32260 and #37627, has active contributor interest (someone has volunteered to work on it), and directly describes the root cause: Superset's pandas-based post-processing treats all numeric metric outputs as additive, losing the original SQL formula context [[12]](https://github.com/apache/superset/issues/38674#issuecomment-4066762404). The architectural discussion in [#29297](https://github.com/apache/superset/discussions/29297) is also a good companion for solution design.
The core issue spans pivot tables *and* regular table charts, so it may be worth noting in the consolidation thread that any architectural fix should cover both chart types.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=too_verbose) | [Hallucination](https://
app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other#message_id=ff15bcea-4cb0-4134-a5df-c0f197748501&feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=Yes%20%E2%80%94%20there%20are%20quite%20a%20few%21%20Here%27s%20what%20I%20found%20across%20open%20issues%2C%20discussions%2C%20and%20proposals%20all%20related%20to%20incorrect%20subtotal/total%20calculations%20in%20pivot%20tables%20and%20table%20charts%3A%0A%0A%2A%2AOpen%20Bug%20Reports%3A%2A%2A%0A%0A-%20%5B%2A%2A%2338674%2A%2A%5D%28https%3A//github.com/apache/superset/issues/38674%29%20%E2%80%94%20Grand%20Total%20sums%20percentages%20instead%20of%20re-calculating%20the%20metric%20%5B%5B1%5D%5D%28https%3A//github.com/apache/superset/issues/38674%29%0A-%20%2A%2A%2332260%2A%2A%20%28this%20issue%29%20%E2%80%94%20Subtotal/sum%20of%20completion%20percentage%20is%20wrong%20in%20
pivot%20tables%0A-%20%5B%2A%2A%2336165%2A%2A%5D%28https%3A//github.com/apache/superset/issues/36165%29%20%E2%80%94%20Table%20visual%20summary%20value%20not%20matching%20for%20COUNT_DISTINCT%20%5B%5B2%5D%5D%28https%3A//github.com/apache/superset/issues/36165%29%0A-%20%5B%2A%2A%2339223%2A%2A%5D%28https%3A//github.com/apache/superset/issues/39223%29%20%E2%80%94%20DISTINCT_AVG%20/%20DISTINCT_SUM%20broken%20in%20v6%20%28regression%29%20%5B%5B3%5D%5D%28https%3A//github.com/apache/superset/issues/39223%29%0A-%20%2A%2A%2325747%2A%2A%20%E2%80%94%20Referenced%20as%20the%20original%20issue%20that%20PR%20%2334592%20targets%0A%0A%2A%2AOpen%20Feature%20Requests%20/%20Proposals%3A%2A%2A%0A%0A-%20%5B%2A%2A%2338586%2A%2A%5D%28https%3A//github.com/apache/superset/issues/38586%29%20%E2%80%94%20%5BSIP-205%5D%20Proposal%20for%20AntV%20S2-based%20Pivot%20Table%2C%20which%20identifies%20incorrect%20aggregation%20as%20a%20core%20motivation%20%5B%5B4%5D%5D%28https%3A//github.com/apache/superset/issues/38586
%29%0A-%20%5B%2A%2A%2338036%2A%2A%5D%28https%3A//github.com/apache/superset/discussions/38036%29%20%E2%80%94%20Per-metric%20aggregation%20function%20in%20Pivot%20Table%20V2%20%5B%5B5%5D%5D%28https%3A//github.com/apache/superset/discussions/38036%29%0A-%20%2A%2A%2334245%2A%2A%20%E2%80%94%20%5BSIP-179%5D%20Enhanced%20aggregation%20customization%20in%20totals/subtotals%20%5B%5B6%5D%5D%28https%3A//github.com/apache/superset/issues/34245%29%0A-%20%5B%2A%2A%2335089%2A%2A%5D%28https%3A//github.com/apache/superset/issues/35089%29%20%E2%80%94%20Rename%20%22Subtotal%22%20to%20%22Subvalue%22%20%28misleading%20labels%20for%20non-sum%20aggregations%29%20%5B%5B7%5D%5D%28https%3A//github.com/apache/superset/issues/35089%23issuecomment-4156939275%29%0A%0A%2A%2AClosed%20%28as%20duplicates%20/%20insufficient%20info%2C%20not%20actually%20fixed%29%3A%2A%2A%0A%0A-%20%5B%2A%2A%2334350%2A%2A%5D%28https%3A//github.com/apache/superset/issues/34350%29%2C%20%5B%2A%2A%2334425%2A%2A%5D%28https%3A//github.com/ap
ache/superset/issues/34425%29%2C%20%5B%2A%2A%2334426%2A%2A%5D%28https%3A//github.com/apache/superset/issues/34426%29%20%E2%80%94%20Percentage%20calculation%20issues%20in%20tables%20with%20pagination%20%5B%5B8%5D%5D%28https%3A//github.com/apache/superset/issues/34350%23issuecomment-3126342060%29%20%5B%5B9%5D%5D%28https%3A//github.com/apache/superset/issues/34425%29%0A%0A%2A%2AArchitectural%20Discussion%3A%2A%2A%0A%0A-%20%5B%2A%2A%2329297%2A%2A%5D%28https%3A//github.com/apache/superset/discussions/29297%29%20%E2%80%94%20Totals%20in%20Table%20Charts%20%28comprehensive%20discussion%20of%20the%20root%20cause%29%20%5B%5B10%5D%5D%28https%3A//github.com/apache/superset/discussions/29297%29%0A%0A%2A%2ARelated%20PR%20%28open%2C%20unmerged%20for%20~9%20months%29%3A%2A%2A%0A%0A-%20%5B%2A%2APR%20%2334592%2A%2A%5D%28https%3A//github.com/apache/superset/pull/34592%29%20%E2%80%94%20%22fix%28pivot-table%29%3A%20Correct%20totals%20for%20non-additive%20metrics%22%20%E2%80%94%20proposes%20a%20multi-que
ry%20architecture%20%5B%5B11%5D%5D%28https%3A//github.com/apache/superset/pull/34592%29%0A%0A%2A%2A%2A%0A%0A%2A%2ASuggested%20%22main%22%20thread%20for%20consolidation%3A%2A%2A%20I%27d%20recommend%20%2A%2A%5B%2338674%5D%28https%3A//github.com/apache/superset/issues/38674%29%2A%2A%20as%20the%20primary%20consolidation%20point.%20It%27s%20the%20most%20recent%20and%20well-described%20bug%20report%2C%20already%20cross-references%20%2332260%20and%20%2337627%2C%20has%20active%20contributor%20interest%20%28someone%20has%20volunteered%20to%20work%20on%20it%29%2C%20and%20directly%20describes%20the%20root%20cause%3A%20Superset%27s%20pandas-based%20post-processing%20treats%20all%20numeric%20metric%20outputs%20as%20additive%2C%20losing%20the%20original%20SQL%20formula%20context%20%5B%5B12%5D%5D%28https%3A//github.com/apache/superset/issues/38674%23issuecomment-4066762404%29.%20The%20architectural%20discussion%20in%20%5B%2329297%5D%28https%3A//github.com/apache/superset/discussions/29297%29%20is%
20also%20a%20good%20companion%20for%20solution%20design.%0A%0AThe%20core%20issue%20spans%20pivot%20tables%20%2Aand%2A%20regular%20table%20charts%2C%20so%20it%20may%20be%20worth%20noting%20in%20the%20consolidation%20thread%20that%20any%20architectural%20fix%20should%20cover%20both%20chart%20types.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/32260)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-4738470972
Going to consolidate all the non-additive subtotal/total issues onto #25747. Carried over the completion-percentage example and the Excel-style in-cell formula idea you all floated. Closing in favor of that thread, follow along there :)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "ng22t7a (via GitHub)" <gi...@apache.org>.
ng22t7a commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-2753590029
hi @Kuaffu, have you find out how to fix this?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "alex241728 (via GitHub)" <gi...@apache.org>.
alex241728 commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-3358023515
> Has anyone been able to find a solution to this issue? I'm specifically trying to identify where in the code the percentage values are being summed up incorrectly in the pivot table. Any pointers on which file or function handles subtotal calculations for percentage fields would be really helpful. Thanks!
@nyatitilkesh I think you misunderstood the problem. The sum is not incorrect. Superset is not as smart as humans. When it is doing subtotals, it just sums the totals of all the grids on its top. However, the poster wants the subtotal to be the division of the two grids on the right.
Compared to superset, excel allows users to insert a function inside the grid to calculate the answers. Do you think superset needs such a tool? @rusackas
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "Kuaffu (via GitHub)" <gi...@apache.org>.
Kuaffu commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-2661746830
> Hey [@Kuaffu](https://github.com/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!
>
> 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:
>
> 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 [[1]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.js).
>
> _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._
>
> 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)
This only solves the current issue. When actual_amount or target_amount is not dragged, it still cannot calculate sum(actual_amount) / sum(target_amount)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] Issue with Incorrect Subtotal and Sum Calculation of Completion Percentage in Pivot Table [superset]
Posted by "ningauble (via GitHub)" <gi...@apache.org>.
ningauble commented on issue #32260:
URL: https://github.com/apache/superset/issues/32260#issuecomment-3691856256
> Definitely open to proposals!
Could it be configured text formula in subtotal properties like "round((column1 / column2) * 100, 2)" taken from table names?
I just made @ningauble/js-expression-evaluator as a PoC to show an idea with hardcoded available math operations and functions.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org