Comparitve Gauge Last Week Vs This Week
I'm trying to create a card to show last week's sales Vs current week's sales, I'm but having issues with the values my beast modes are returning.
The week should start on Monday and end on Sunday. I have our fiscal calendar enabled and checked so I'm not sure if that's causing the issue or not.
Last Week: SUM((CASE WHEN (((YEAR(`filter_date`) = YEAR(CURDATE())) AND (WEEKOFYEAR(`filter_date`) = (WEEKOFYEAR(CURDATE()) - 1))) AND (DAYOFWEEK(`filter_date`) <= (DAYOFWEEK(CURRENT_DATE) - 1))) THEN `premium_amount` END))
This Week: SUM((CASE WHEN (((Year(`filter_date`) = Year(CURDATE())) AND (WEEKOFYEAR(`filter_date`) = WEEKOFYEAR(CURDATE()))) AND (DAYOFWEEK(`filter_date`) <= (DAYOFWEEK(CURRENT_DATE) - 1))) THEN `premium_amount` END))
Best Answers
-
Hi @Mike_Shrift
What specific issues are you having with the values? Without understanding the problem it's hard to help fix it.
Whenever I'm doing Period over Period analysis I utilize a custom date dimension table to help identify this week vs last week for example. I've outlined this process before in the dojo here: A more flexible way to do Period over Period comparisons
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
Hey, @GrantSmith I'll take a look at the link and let you know if I have any questions.
I'm just not getting the correct results for last week's sales or this week's sales from either of those.
I'm not having any issues with Month to Date and Last Month. I just can't figure out these weekly ones for some reason.
0 -
I plugged your beast modes into a card and replaced your fields with fields from my dataset and I got the correct numbers I would expect for my dataset. That tells me there is likely a data issue either with the filter dates or the premium amounts. I would also check for what field is used in your date range filter and if you have anything in your sorting or filtering properties that would affect it.
I'm also not sure your formulas will work for when the end of the year comes and you need to compare the first week of January with the last week of December. You may want to think about a different option so it will handle that cleanly.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Answers
-
Hi @Mike_Shrift
What specific issues are you having with the values? Without understanding the problem it's hard to help fix it.
Whenever I'm doing Period over Period analysis I utilize a custom date dimension table to help identify this week vs last week for example. I've outlined this process before in the dojo here: A more flexible way to do Period over Period comparisons
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
Hey, @GrantSmith I'll take a look at the link and let you know if I have any questions.
I'm just not getting the correct results for last week's sales or this week's sales from either of those.
I'm not having any issues with Month to Date and Last Month. I just can't figure out these weekly ones for some reason.
0 -
I plugged your beast modes into a card and replaced your fields with fields from my dataset and I got the correct numbers I would expect for my dataset. That tells me there is likely a data issue either with the filter dates or the premium amounts. I would also check for what field is used in your date range filter and if you have anything in your sorting or filtering properties that would affect it.
I'm also not sure your formulas will work for when the end of the year comes and you need to compare the first week of January with the last week of December. You may want to think about a different option so it will handle that cleanly.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive