Bars order in stacked bar chart #7625
Labels
Type:New Feature
Visualization/Chart Settings
Visualization/Charts
Line, area, bar, combo, and scatter charts.
Milestone
Hi,
Is it possible to sort stacked bars based on the total bar height? Right now it defaults to first all the bars of the first subcategory, then all the bars of the 2nd subcategory which are not in there yet, following by all the bars of the 3rd subcategory which are not in there yet, and so on (figure 1).
I tried sorting the output on the total number of reviews (the total bar height) beforehand (figure 2), but without the desired effect: this only orders the bars relative to their subcategory.
Objective: Make a stacked bar chart with first all bars with total height 3, than with total height 2 and finally with height 1.
See below for the used SQL .
Figures
Figure 1: Stacked bar chart without ordering query output
Figure 2: Stacked bar chart with query output ordered on total bar height
SQL
SELECT *
FROM
(
Select reviews.reviewer, COUNT() AS NumberReviewsPerPerson
FROM reviews
WHERE reviews.reviewer IN ('delbert', 'deangelo', 'darren', 'genesis', 'rhea', 'herta', 'malcolm', 'timmy', 'adalberto')
GROUP BY reviews.reviewer
) t1
LEFT JOIN (
Select reviews.reviewer, products.category, COUNT() as NumberReviewsPerPersonPerCategory
FROM reviews
LEFT JOIN products ON (products.id = reviews.product_id)
GROUP BY reviews.reviewer, products.category
) t2
ON (t1.reviewer = t2.reviewer)
Related #2339
⬇️ Please click the 👍 reaction instead of leaving a
+1
orupdate?
commentThe text was updated successfully, but these errors were encountered: