Bug in Cumulative Sum Calculation in Metabase v0.50 #47613
Labels
Priority:P1
Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness
Querying/GUI
Query builder catch-all, including simple mode
.Regression
Bugs that were previously fixed and/or bugs unintentionally shipped with new features.
.Team/Querying
Type:Bug
Product defects
Milestone
Describe the bug
I've encountered a bug with the cumulative sum calculation in Metabase version 0.50.xx that didn't exist in version 0.48 (I use 0.50.18 version)
In version 0.48, creating a cumulative sum of quantities sorted by categories worked correctly. However, in version 0.50, the cumulative sum does not sort properly
i have post this in discourse :
https://discourse.metabase.com/t/bug-in-cumulative-sum-calculation-in-metabase-v0-50/144567/10
To Reproduce
herebelow is SQL code autogenerate by metabase 0.50.17
SELECT
"source"."Products__CATEGORY" AS "Products__CATEGORY",
SUM("source"."QUANTITY") AS "sum",
SUM(SUM("source"."QUANTITY")) OVER (
ORDER BY
"source"."Products__CATEGORY" ASC ROWS UNBOUNDED PRECEDING
) AS "sum_2"
FROM
(
SELECT
"Products"."CATEGORY" AS "Products__CATEGORY",
"PUBLIC"."ORDERS"."QUANTITY" AS "QUANTITY"
FROM
"PUBLIC"."ORDERS"
LEFT JOIN "PUBLIC"."PRODUCTS" AS "Products" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "Products"."ID"
) AS "source"
GROUP BY
"source"."Products__CATEGORY"
ORDER BY
"sum" DESC,
"source"."Products__CATEGORY" ASC
this is the screenshot
Expected behavior
Expected result: The cumulative sum should start with the value 18.920 as the first row (corresponding to the sum quantity column), but the result was started with 69540
as comparation, using the same steps in producing the cumulative with 0.48 herebelow SQL code autogenerate by metabase 0.48
SELECT
"Products"."CATEGORY" AS "Products__CATEGORY",
SUM("PUBLIC"."ORDERS"."QUANTITY") AS "sum",
SUM("PUBLIC"."ORDERS"."QUANTITY") AS "sum_2"
FROM
"PUBLIC"."ORDERS"
LEFT JOIN "PUBLIC"."PRODUCTS" AS "Products" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "Products"."ID"
GROUP BY
"Products"."CATEGORY"
ORDER BY
"sum" DESC,
"Products"."CATEGORY" ASC
screenshot :
https://discourse.metabase.com/uploads/default/original/3X/9/c/9cbd5b5440140011a7317830e71217625f93a0c4.png
the result is correct.
you can see the difference.
I think this is big issue that make metabase don't have ability to make pareto diagram anymore. Which is common in analytic jobs
Logs
No response
Information about your Metabase installation
Severity
I think this is substantial problem, Urgent to resolve
Additional context
No response
The text was updated successfully, but these errors were encountered: