Using aggregation in case statements
I have a data set of sales where a sale is either a "new sale" or an "add sale". This value is stored in `calcSaleType`. I would like to graph the ratio of new sales to add sales over time but keep turning up null values.
The value of a sale is stored in `total_cost`.
I've tried the following with no luck:
(case when `sale_type`='new sale' then sum(`total_cost`) end) / (case when `sale_type`='add sale' then sum(`total_cost`) end)
Even when I try simply graphing the following, I get mostly null values even though every row contains a `calcSaleType` value. What am I missing here?
- 10.6K All Categories
- 13 Getting Started in the Community
- 29 Beastmode & Analytics
- 2.1K Data Platform & Data Science
- 59 Domo Everywhere
- 2.7K Charting
- 2.4K Ideas Exchange
- 1.3K Connectors
- 362 Workbench
- 300 Use Cases & Best Practices
- 499 APIs
- 118 Apps
- 48 News
- 753 Onboarding
- 1.1K 日本支部
- 4 Private Company Board