Is this doable? Seeing percent of total day sales by hour using Timestamp column.
Hello!
I have a problem that needs to be visualized and it was phrased to me like this: I need to see what percentage of sales each hour had for the total day last year then I need that percentage multiplied by the daily goal to get an hourly goal for today. So we have this chart right now:
this show us net sales today, yesterday, and LY. The LY isn't working right now just because there's a hole in the data for the next week. Anyways, we want to be able to have a goal or bar that shows goal per hour based on percentage of total day LY if that makes sense.
Now for this data, each row is an item in an order so if a order has 3 items in it then one order has 3 lines. I have a timestamp column that acts as my date column and a Net Sales column already so each line has a total net sales #. Is there a way to do this? If this makes any sense I don't know but I have almost just ripped out my hair trying to figure out window and rank functions or group by functions to figure this out. If anyone can help me walk through this that would be greatly appreciated.
Answers
-
Hi @DANIH
Have you tried a window function with a case statement since you're attempting to only look at data from today?
Last Year:
SUM(SUM(CASE WHEN DATE(`Timestamp`) = CURRENT_DATE - INTERVAL '1' YEAR THEN `Net Sales` END)) OVER (PARTITION BY HOUR(`Timestamp`))
Last Year (With day of week aligned)
SUM(SUM(CASE WHEN DATE(`Timestamp`) = CURRENT_DATE - INTERVAL '364' DAY THEN `Net Sales` END)) OVER (PARTITION BY HOUR(`Timestamp`))
Yesterday:
SUM(SUM(CASE WHEN DATE(`Timestamp`) = CURRENT_DATE - INTERVAL '1' DAY THEN `Net Sales` END)) OVER (PARTITION BY HOUR(`Timestamp`))
Today:
SUM(SUM(CASE WHEN DATE(`Timestamp`) = CURRENT_DATE THEN `Net Sales` END)) OVER (PARTITION BY HOUR(`Timestamp`))
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Would these be in my beast mode or formula tile in etl? @GrantSmith
0 -
Whenever I am needing to show a goal, I tend to use the Bullet Chart, so I would suggest looking at that for your visualization.
https://domohelp.domo.com/hc/en-us/articles/360042924154-Bullet-Chart
As for the data, I would start with adding a group by to total your orders by datetime, so that you have one row for each datetime interval you want. I would then add a formula tile that creates a datetime field of one year prior. You can use DATE_SUB to do this. I would then join on this field back to your original dataset so that you have the prior year's value next to the current year value. I would do a left join in case there is no match. You can then do the math to create your goal in another formula tile.
This should lay out the data nicely to easily drop into a bullet chart.
**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.0 -
I did these in beast mode and it worked but its basically what I had before. I need to be able to take the percentage that each hour had Last year for the total day and times that by today goal column. What's the next step for that? @GrantSmith
0 -
@DANIH Do you have some sample anonymized data I could play with?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Here is something I just made up. I have a timestamp column with todays net sales for example it only goes through hour to date. Then I have last years net sales. There is a goal column so if we can figure out what each hour percent total for the whole day was for last year then times that by the goal for today for each hour we could get a dollar amount per hour that I need to hit in order to reach the goal for today. Hopefully that makes sense. I don't know if this is possible but hopefully we can figure something out! To better understand I added this Excel to show what I want it to look like. The Date column might be weird but you can fix that I'm guessing.
0
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
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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