Summing up sales for previous year
Hello -
I'm trying to pull into a table on my card the following:
Current Year Sales
Previous Year Sales
The calculation I'm using for previous year sales in beast mode is
CASE
WHEN YEAR(current_date()) = YEAR(`week_beginning`) - 1
THEN SUM(`sales`)
ELSE 0
END
or
sum(CASE
WHEN YEAR(current_date()) = YEAR(`week_beginning`) - 1
THEN `sales`
ELSE 0
END)
but I'm getting a value of 0 for previous year sales.
The data is aggregated weekly data we receive from a partner.
Thank you
Comments
-
I think the likely solution is that on the card itself, you need to specify the date range to include the previous 2 years, like pictured in the attached.
Let me know if that helps.
0 -
I think that you are subtracting 1 from the wrong year field:
try this.
sum(CASE
WHEN YEAR(current_date())-1 = YEAR(`week_beginning`)
THEN `sales`
ELSE 0
END)
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman0 -
Moving the 1 to the first instance worked on some level, but only when I pull in a long date range, i.e., 2 years. What I'm trying to do though, is pull sales for any date range, say 1 week or 1 month and compare those sales to the previous year sales during the same time frame. I tried using this query
sum(CASE
WHEN year(`week_beginning`)-1 = year(`week_beginning`)
THEN `sales`
ELSE 0
END)Which instead of using current_date() in the first instance, I use week beginning in hopes that whatever week I want to look at for this year, it will bring in previous year sales for the same week. This isn't working either, however.
0 -
Have you looked into the period over period graphs?
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive