derichev-ozon opened a new issue, #21455: URL: https://github.com/apache/superset/issues/21455
Currelty Superset (v.1.5.1 and also in v.2.0.0) for Chart PivotTable (v1 and v2) doesn't corrently count total/subtotal (SUM aggregation) in case of division metric exists. For example: Let's create PivotTable, add metrics and populate as following  Where is "proc" column is metric with function "SUM(fm) / SUM(gmv)" . As you can see Total (Sum) is **2.7** , but it should be 165M / 376M ~= **0.4388** . So Superset just SUM column "proc" values instead of direct division. #### How to reproduce the bug 1. Create dataset "default.test_pivot", for instance using following SQL: ``` SELECT 34523.323 as gmv, 24523.323 as fm, '1' as shem, '1' as gr UNION all SELECT 325323543.323 as gmv, 125323543.323 as fm, '2' as shem, '1' as gr UNION all SELECT 5764545.323 as gmv, 4764545.323 as fm, '3' as shem, '2' as gr UNION all SELECT 45254525.323 as gmv, 35254525.323 as fm, '4' as shem, '2' as gr ``` 2. Create Chart PivotTable v2 (visualization type = Pivot Table v2) based on dataset above. 3. Populate rows as "gr" (Simple ABC gr) and "shem" (Simple ABC shem) 4. Create metrics: - SUM(gmv) (Simple , Column = gmv, aggregate = SUM) - SUM(fm) (Simple , Column = fm, aggregate = SUM) - proc (Custom SQL with value SUM(fm) / SUM(gmv) ) 5. In the Options area check "Show columns total" and select Aggregation functiona as "SUM" 6. Run (evaluate values for Chart) ### Expected results Total (Sum) should be 165M / 376M ~= **0.4388** . The same for Subtotal correspondingly ### Actual results Total (Sum) is **2.7** , just SUM column "proc" values instead of direct division. #### Screenshots See above. ### Environment - browser type and version: chrome 105.0.5195.102 (64bit version) - superset version: 1.5.1 - python version: 3.8.12 - node.js version: any - any feature flags active: any ### Checklist Checked: - [x] I have checked the superset logs for python stacktraces and included it here as text if there are any. - [x] I have reproduced the issue with at least the latest released version of superset. - [x] I have checked the issue tracker for the same issue and I haven't found one similar. ### Additional context If some workaround exists it will be also good. -- 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]
