Recipe Tableau and SQL
Which few products make most of your revenue?
Total revenue per product, sort from largest to smallest, and divide the running total by the grand total. In this store, 12 of 40 products (30%) make 80% of revenue: not quite 80/20, which is normal.
The data
Kettle & Burr coffee-gear store, orders in 2025
A small online store selling 40 products: brewers, grinders, kettles, beans and accessories. 1,200 orders in 2025.
order_id | order_date | product | category | quantity | revenue |
|---|---|---|---|---|---|
| O-10946 | 2025-01-01 | Paper Filters 100 | Filters & Care | 1 | 13.76 |
| O-10304 | 2025-01-02 | AeroPress Go | Brewers | 1 | 61.55 |
| O-10657 | 2025-01-02 | Ethiopia Yirgacheffe 250g | Beans | 3 | 58.68 |
| O-10912 | 2025-01-02 | Ethiopia Yirgacheffe 250g | Beans | 1 | 19.56 |
Step 1
Total each product
Each bar is one product's total for the year. A few tall bars, then a long tail: that shape is what Pareto analysis measures.
Tableau
SUM([revenue])The xmetric engine ran this formula and got the SQL’s Revenue column, row for row.
SQL
SELECT product, SUM(revenue) AS total
FROM input
GROUP BY productRows
| Product | Revenue |
|---|---|
| AeroPress Go | $11,264 |
| Ethiopia Yirgacheffe 250g | $11,032 |
| Burr Grinder Pro | $8,964 |
| Gooseneck Kettle Electric | $7,921 |
| Paper Filters 100 | $2,119 |
| Pour-Over Dripper | $1,734 |
| House Espresso 1kg | $1,664 |
| Travel Tumbler | $1,585 |
| Grinder Brush Set | $1,555 |
| Tamper 58mm | $1,510 |
| Hand Grinder Mini | $1,453 |
| Gooseneck Kettle Stovetop | $1,286 |
| Coaster Set | $1,219 |
| Clever Dripper | $966 |
| Kenya AA 250g | $962 |
| Burr Grinder Lite | $953 |
| Milk Frother | $751 |
| Decaf Swiss Water 250g | $739 |
| Siphon Brewer | $685 |
| Glass Server 600ml | $644 |
| Coffee Scale | $536 |
| French Press 1L | $514 |
| Chemex 8-Cup | $464 |
| Storage Canister | $459 |
| Cold Brew Jar | $420 |
| Moka Pot 6-Cup | $363 |
| Filter Holder | $361 |
| Cloth Filter 2-Pack | $322 |
| Ceramic Mug | $284 |
| Guatemala Antigua 250g | $260 |
| Colombia Huila 250g | $255 |
| Travel Kettle | $219 |
| Gift Card 50 | $163 |
| Knock Box | $134 |
| Barista Apron | $132 |
| Latte Art Pitcher | $108 |
| Cleaning Tablets | $101 |
| Brazil Santos 1kg | $86 |
| Seasonal Single Origin 250g | $71 |
| Descaler | $70 |
Step 2
Add up from the top
The line is the share of the year's total covered so far. Compute it in descending order of the bars; in Tableau, set Compute Using to product and sort product by the measure, descending.
Tableau
RUNNING_SUM(SUM([revenue])) / TOTAL(SUM([revenue]))SQL
WITH t AS (
SELECT product, SUM(revenue) AS total
FROM input
GROUP BY product
)
SELECT
product,
total,
SUM(total) OVER (ORDER BY total DESC, product ROWS UNBOUNDED PRECEDING)
/ SUM(total) OVER () AS cumulative_share
FROM t
ORDER BY total DESC, productRows
| Product | Revenue | Cumulative share |
|---|---|---|
| AeroPress Go | $11,264 | 17.5% |
| Ethiopia Yirgacheffe 250g | $11,032 | 34.7% |
| Burr Grinder Pro | $8,964 | 48.6% |
| Gooseneck Kettle Electric | $7,921 | 60.9% |
| Paper Filters 100 | $2,119 | 64.2% |
| Pour-Over Dripper | $1,734 | 66.9% |
| House Espresso 1kg | $1,664 | 69.5% |
| Travel Tumbler | $1,585 | 72% |
| Grinder Brush Set | $1,555 | 74.4% |
| Tamper 58mm | $1,510 | 76.7% |
| Hand Grinder Mini | $1,453 | 79% |
| Gooseneck Kettle Stovetop | $1,286 | 81% |
| Coaster Set | $1,219 | 82.9% |
| Clever Dripper | $966 | 84.4% |
| Kenya AA 250g | $962 | 85.9% |
| Burr Grinder Lite | $953 | 87.3% |
| Milk Frother | $751 | 88.5% |
| Decaf Swiss Water 250g | $739 | 89.7% |
| Siphon Brewer | $685 | 90.7% |
| Glass Server 600ml | $644 | 91.7% |
| Coffee Scale | $536 | 92.6% |
| French Press 1L | $514 | 93.4% |
| Chemex 8-Cup | $464 | 94.1% |
| Storage Canister | $459 | 94.8% |
| Cold Brew Jar | $420 | 95.4% |
| Moka Pot 6-Cup | $363 | 96% |
| Filter Holder | $361 | 96.6% |
| Cloth Filter 2-Pack | $322 | 97.1% |
| Ceramic Mug | $284 | 97.5% |
| Guatemala Antigua 250g | $260 | 97.9% |
| Colombia Huila 250g | $255 | 98.3% |
| Travel Kettle | $219 | 98.7% |
| Gift Card 50 | $163 | 98.9% |
| Knock Box | $134 | 99.1% |
| Barista Apron | $132 | 99.3% |
| Latte Art Pitcher | $108 | 99.5% |
| Cleaning Tablets | $101 | 99.6% |
| Brazil Santos 1kg | $86 | 99.8% |
| Seasonal Single Origin 250g | $71 | 99.9% |
| Descaler | $70 | 100% |
Step 3
Turn products into a share too
With both axes as shares, any dataset fits the same square. Where the curve crosses the cutoff line, read off the share of products that got you there.
Tableau
INDEX() / SIZE()SQL
WITH t AS (
SELECT product, SUM(revenue) AS total
FROM input
GROUP BY product
), r AS (
SELECT
product,
total,
ROW_NUMBER() OVER (ORDER BY total DESC, product) AS k,
COUNT(*) OVER () AS n,
SUM(total) OVER (ORDER BY total DESC, product ROWS UNBOUNDED PRECEDING)
/ SUM(total) OVER () AS cumulative_share
FROM t
)
SELECT product, k * 1.0 / n AS product_share, cumulative_share
FROM r
ORDER BY kRows
| Product | Product share | Cumulative share |
|---|---|---|
| AeroPress Go | 2.5% | 17.5% |
| Ethiopia Yirgacheffe 250g | 5% | 34.7% |
| Burr Grinder Pro | 7.5% | 48.6% |
| Gooseneck Kettle Electric | 10% | 60.9% |
| Paper Filters 100 | 12.5% | 64.2% |
| Pour-Over Dripper | 15% | 66.9% |
| House Espresso 1kg | 17.5% | 69.5% |
| Travel Tumbler | 20% | 72% |
| Grinder Brush Set | 22.5% | 74.4% |
| Tamper 58mm | 25% | 76.7% |
| Hand Grinder Mini | 27.5% | 79% |
| Gooseneck Kettle Stovetop | 30% | 81% |
| Coaster Set | 32.5% | 82.9% |
| Clever Dripper | 35% | 84.4% |
| Kenya AA 250g | 37.5% | 85.9% |
| Burr Grinder Lite | 40% | 87.3% |
| Milk Frother | 42.5% | 88.5% |
| Decaf Swiss Water 250g | 45% | 89.7% |
| Siphon Brewer | 47.5% | 90.7% |
| Glass Server 600ml | 50% | 91.7% |
| Coffee Scale | 52.5% | 92.6% |
| French Press 1L | 55% | 93.4% |
| Chemex 8-Cup | 57.5% | 94.1% |
| Storage Canister | 60% | 94.8% |
| Cold Brew Jar | 62.5% | 95.4% |
| Moka Pot 6-Cup | 65% | 96% |
| Filter Holder | 67.5% | 96.6% |
| Cloth Filter 2-Pack | 70% | 97.1% |
| Ceramic Mug | 72.5% | 97.5% |
| Guatemala Antigua 250g | 75% | 97.9% |
| Colombia Huila 250g | 77.5% | 98.3% |
| Travel Kettle | 80% | 98.7% |
| Gift Card 50 | 82.5% | 98.9% |
| Knock Box | 85% | 99.1% |
| Barista Apron | 87.5% | 99.3% |
| Latte Art Pitcher | 90% | 99.5% |
| Cleaning Tablets | 92.5% | 99.6% |
| Brazil Santos 1kg | 95% | 99.8% |
| Seasonal Single Origin 250g | 97.5% | 99.9% |
| Descaler | 100% | 100% |
Step 4
Label the A, B and C products
A products carry the business, B products support it, C products are the tail. The product that crosses the cutoff is the first B product; some teams count it as A.
Tableau
IF RUNNING_SUM(SUM([revenue])) / TOTAL(SUM([revenue])) <= 0.8 THEN "A"
ELSEIF RUNNING_SUM(SUM([revenue])) / TOTAL(SUM([revenue])) <= 0.95 THEN "B"
ELSE "C"
ENDSQL
WITH t AS (
SELECT product, SUM(revenue) AS total
FROM input
GROUP BY product
), r AS (
SELECT
product,
total,
SUM(total) OVER (ORDER BY total DESC, product ROWS UNBOUNDED PRECEDING)
/ SUM(total) OVER () AS cumulative_share
FROM t
)
SELECT
product,
total,
CASE
WHEN cumulative_share <= 0.8 THEN 'A'
WHEN cumulative_share <= 0.95 THEN 'B'
ELSE 'C'
END AS segment
FROM r
ORDER BY total DESC, productRows
| Product | Revenue | Segment |
|---|---|---|
| AeroPress Go | $11,264 | A |
| Ethiopia Yirgacheffe 250g | $11,032 | A |
| Burr Grinder Pro | $8,964 | A |
| Gooseneck Kettle Electric | $7,921 | A |
| Paper Filters 100 | $2,119 | A |
| Pour-Over Dripper | $1,734 | A |
| House Espresso 1kg | $1,664 | A |
| Travel Tumbler | $1,585 | A |
| Grinder Brush Set | $1,555 | A |
| Tamper 58mm | $1,510 | A |
| Hand Grinder Mini | $1,453 | A |
| Gooseneck Kettle Stovetop | $1,286 | B |
| Coaster Set | $1,219 | B |
| Clever Dripper | $966 | B |
| Kenya AA 250g | $962 | B |
| Burr Grinder Lite | $953 | B |
| Milk Frother | $751 | B |
| Decaf Swiss Water 250g | $739 | B |
| Siphon Brewer | $685 | B |
| Glass Server 600ml | $644 | B |
| Coffee Scale | $536 | B |
| French Press 1L | $514 | B |
| Chemex 8-Cup | $464 | B |
| Storage Canister | $459 | B |
| Cold Brew Jar | $420 | C |
| Moka Pot 6-Cup | $363 | C |
| Filter Holder | $361 | C |
| Cloth Filter 2-Pack | $322 | C |
| Ceramic Mug | $284 | C |
| Guatemala Antigua 250g | $260 | C |
| Colombia Huila 250g | $255 | C |
| Travel Kettle | $219 | C |
| Gift Card 50 | $163 | C |
| Knock Box | $134 | C |
| Barista Apron | $132 | C |
| Latte Art Pitcher | $108 | C |
| Cleaning Tablets | $101 | C |
| Brazil Santos 1kg | $86 | C |
| Seasonal Single Origin 250g | $71 | C |
| Descaler | $70 | C |