How to schedule out a month with tasks under certain criteria? - arrays

My scenario is that I have a list of different companies. I need to find a date within the month to upgrade them onto a new system. However, for each company, the assigned date must fit under certain criteria.
Example
I want to populate the Upgrade date column with an ideal date.
The upgrade date cannot fall between the Last Old Input date and the Last Old Pay date.
The upgrade date must be between the Last Old Pay date and the First New Input date.
Complications:
1. All companies that have the same value under Parent column must have the same upgrade date.
2. There are ~4 weeks in a month. I want the upgrade dates to be spread as evenly as possible throughout the weeks. So as close to 25% of all companies per week. Therefore if there are more than one viable upgrade date possibilities, try to fill out the month as evenly as possible. (If COUNT = 1/4 total companies, go to next week type deal)
3. Within the week itself, I want the upgrade date to be the same day if possible. Example: all on Monday of that week, all on Friday of that week.
So to start:
Is there a way to create an array formula that can read each company one by one, and produce out a list of possible list of dates for that company. So for company 112, I know that 8/27-8/30 are blacked out. I know that the date should be between 8/30 and 9/10. How can I get Excel to auto-populate all the options out (8/31, 9/1, 9/2, 9/3, etc.)?
And then be able to group all companies together that are under the same Parent, and find a common upgrade date that works for all of the companies combined?

Related

Do MWS API report time limits apply to data being added or data within the report?

I’m looking specifically at the FBA Customer Shipment Sales Report report, but I believe the question applies more generally to most reports.
One of the columns in the report is the “Shipment Date”. When I request this report via the MWS API, I can specify a StartDate and an EndDate. Do these dates filter on the “Shipment Date” column, or do they instead filter based on the date that the data was added to the report?
For example, if an order ships at 2019-07-29T12:00:00Z, but Amazon doesn’t actually add it to the report until an hour later at 2019-07-29T13:00:00Z, then if I generate this report with an EndDate of 2019-07-29T12:00:00Z, will this shipment appear in the report? Or will it only appear if the EndDate is greater than or equal to 2019-07-29T13:00:00Z since that’s the time the shipment was actually added to the report?
I understand that in general this report is near real-time, so it may not matter 99% of the time, but I’m concerned about the rare times where the data my be delayed coming into the report. I want to make sure I will still be able to see the new data based on my data filters.
I think I found my answer here: https://sellercentral.amazon.com/gp/help/200453120?language=en_US&ref=ag_200453120_cont_201074420
It says:
The report contains all completed shipments reported to FBA during the specified time period. This may not include all items that were shipped during that time frame if they have not yet been reported to our system. Those items will be reported in a future time period. This ensures that the report data will always be consistent for any given date range.
And:
Shipment dates are based on when the shipment was reported to the system, which is generally a few hours after the actual ship date. Other reports may calculate shipment dates differently.
So the answer is actually that the "Shipment Date" is the date the shipment was reported and added to the report, which is not necessarily the same as the date and time the shipment actually took place.

Database Design: How do I handle tracking goals vs. actuals over time?

This isn't exactly a programming question, as I don't have an issue writing the code, but a database design question. I need to create an app that tracks sales goals vs. actual sales over time. The thing is, that a persons goal can change (let's say daily at most).
Also, a location can have multiple agents with different goals that need to be added together for the location.
I've considered basically running a timed task to save daily goals per agent into a field. It seems that over the years that will be a lot of data, but it would let me simply query a date range and add all the daily goals up to get an goal for that date range.
Otherwise, I guess I could simply write changes (i.e. March 2nd - 15 sales / week, April 12th, 16 sales per week) which would be less data, but much more programming work to figure out goals based on a time query.
I'm assuming there is probably a best practice for this - anyone?
Put a date range on your goals. The start of the range is when you set that goal. The end of the range starts off as max-collating date (often 9999-12-31, depending on your database).
Treat this as "until forever" or "until further notice".
When you want to know what goals were in effect as of a particular date, you would have something like this in your WHERE clause:
...
WHERE effective_date <= #AsOfDate
AND expiry_date > #AsOfDate
...
When you change a goal, you need two operations, first you update the existing record (if it exists) and set the expiry_date to the new as-of date. Then you insert a new record with an effective_date of the new as-of date and an expiry_date of forever (e.g. '9999-12-31')
This give you the following benefits:
Minimum number of rows
No scheduled processes to take daily snapshots
Easy retrieval of effective records as of a point in time
Ready-made audit log of changes

Show data over rolling months instead of calendar months in SSAS

I have a cube that shows order volume history, but showing the month to date numbers isn't that useful (since they're way out of whack with other full months). I want to include that data in some kind of display, but in a way that makes sense.
What's the best way to go about showing the last 30 days (or last month) over a previous period? If there's some way I can do that with my time dimension, great, but I figured I might need a calculation of some kind.
For example, since today is 7/12, I'd want to show the data for 6/13-7/12 as the most recent period, and then compare it to 5/13-6/12, and so on - that way, it would be easy to see where the current month is trending, but with values that are inline size-wise with previous periods. Also, I'd figure that would make an easier KPI value, since I can compare movement from last month's values using the rolling one-month period for comparison.

Adding dates into Calendar

I'd like to get your feedback on my current strategy for updating my office hours scheduling system. I'm rewriting it to avoid laborious entry by allowing employees to have a set schedule rather than individually inputting office hours. Is there an easier/normal way for doing it other than what I am planning below?
I am using a simple calendar setup that receives events in an array from an events table and then displays them in a calendar. I want to rework the way events are added into the events table.
Currently: Employees can select a day, and then add individual office hours (Monday 9:00, 10:00, 11:00, 12:00 , 1:00, 2:00, etc.)
Goal: Employees select a set schedule (ex. Mon-Wed-Fri, from 8:00-5:00PST), and the system automatically adds future dates into the events table for display (one month in advance).
Current plan: Add a schedules table with employee ID, and fields for Mon-Sunday. Daily a CRON job runs that checks what day of the week is 28 days from now. It then queries the schedules to find all employees who have hours scheduled on that day of the week. Adds events into the events table 4 weeks in advance.
Is this a satisfactory way of doing it? Thanks! I'm new in coding, so your feedback before spending a lot of time implementing is helpful!
If their schedules are consistent, it makes good sense for each employee to have a default schedule. And it makes sense to have a cron job update the calendar automatically.
But you might give some thought to what should happen when someone wants to schedule vacation time (or make any arbitrary change to their schedule) more than a month into the future. Same issue when the owner wants to see who's scheduled to work over the summer and finds a blank calendar. (The point is that some people will invariably need to know something that the calendar doesn't yet cover. You need to plan for that. )

Database Schema - Booking/Availability System

I was recently asked an interview question on a hypothetical web based booking system and how I would design the database schema to minimize duplication and maximize flexibility.
The use case is that a admin would enter the availability of a property into the system. There could be multiple time period set. For example, 1st of April 2009 to 14th of April 2009 and 3rd of July 2009 to 21st of July 2009.
A user is then only able to place a booking in the periods made available of equal or shorter periods.
How would you store this information in a database?
Would you use something as simple (really simplified) as;
AVAILABILITY(property_id, start_date, end_date);
BOOKING(property_id, start_date, end_date);
Could you then easily construct a web page that showed a calendar of availability with periods that have been booked blanked out. Would it be easy to build reports from this database schema? Is it as easy as it seems?
It might be easier to work with a single table for both availability and booking, with a granularity of 1 day:
property_date (property_id, date, status);
Column status would have (at least) the following 2 values:
Available
Booked
Entering a period of availability e.g. 1st to 14th of April would entail (the application) inserting 14 rows into property_date each with a status of 'Available'. (To the user it should seem like a single action).
Booking the property for the period 3rd to 11th April would entail checking that an 'Available' row existed for each day, and changing the status to 'Booked'.
This model may seem a bit "verbose", but it has some advantages:
Checking availability for any date is easy
Adding a booking automatically updates the availability, there isn't a separate Availability table to keep in sync.
Showing availability in a web page would be very simple
It is easy to add new statuses to record different types of unavailability - e.g. closed for maintenance.
NB If "available" is the most common state of a property, it may be better to reverse the logic so that there is an 'Unavailable' status, and the absence of a row for a date means it is available.

Resources