MS Excel - Find Missing Date values between two dates in a column full of dates - database

I have a master list of SKUs in one table set as a column with a different SKU listed in each row.
I have another table with a daily snapshot of items which I have in stock between 7/1/17 and 7/31/17 in each row. The table shows the item SKU in one column, the warehouse where there is quantity in another column, and the quantity available within that warehouse in another column. There can be multiple occurrences of a SKU on one date if there are quantity in multiple warehouses. The table only lists SKUs on occurrences where there is quantity within a warehouse. If a SKU has no quantity within any of the warehouses on a date, it will not be listed in the table corresponding with that date.
In my table with the master list of SKUs I want to create a column that will show the the number of days within a range of dates (7/1/17 to 7/8/17) in which there were no quantity of the SKU being referenced available in any warehouse.
To show a more precise idea of what it is I am trying to do, I have posted a youtube video here: http://youtu.be/6CWLN6wzaWQ?hd=1

Have a look at the following URLs - I feel partially similar cases are discussed and resolved over there.
It will surely give you some lead to further work on.
How to return multiple values between two dates in excel?
https://answers.microsoft.com/en-us/office/forum/office_2007-excel/finding-missing-dates-in-column/8c49800a-6997-4585-b1f4-abdeaa64e718

Related

Storing many dates for many products in a database

I currently have 'many' products (6k to 14k) stored in a database. I now need for each of the products a price history, to be specific: 20 prices per day.
In a relational database, I would use 2 tables where one describes an item and the other one describes the price at a specific time.
So 1 product has 1 price history.
Would be an appropriate approach to use a relational database for this (in a few months, there are millions of datapoints in the database) or would you use e.g. influx if that suits?
If you have other fields related to the date, then you need three tables:
Product (grandparent)
DateHistory (child to Product, parent to PriceHistory)
PriceHistory (child to DateHistory, grandchild to Product)
The middle table holds the date, the third table holds the time-of-day, with a foreign key to DateHistory.
If you have no other columns along with the date, then collapse to two tables.
Product
PriceHistory (columns include a primary key, a foreign key to Product, the date, the time of day, the price)
In this two-column scheme, if you need to represent twenty prices at various times on a date, you have twenty PriceHistory rows that happen to share the same date value.
If your database offers robust date-time handling facilities, then you could combine date and time together into one field. Let the database group by date when needed using its ability to understand the date-time values.

SSIS/visual studio- using derived column transform to count distinct values and sort by two variables?

I have three columns of data- incident_ID, date, state.
The incident_ID are each unique, date is in year format only and ranges from 2013 to 2016, states are in no particular order and repeat if an incident occurs w/in the same state in the same year.
I'm going to be combining this data w/ another table, but first I need to organize the data to better match the other table's format- which is laid out showing the year, state, and dollars spent per state. So for 2013, I would have 51 rows (each state + DC) and each state would have a dollar amount- then rinse/repeat down the table through to 2016.
I'm pretty new to SSIS/Visual Studio, but from my understanding I should be able to use a Derived Column Transform to accomplish this.... but I don't know how to get there.
Is there a way to use Derived Column to 'count' and rearrange the data in order to show how many incidents occurred per state in the given year?
There is no aggregate (like SUM,Count,Min,Max) functionality in Derive Columnenter code here.For count, you can use ROW COUNT Task or you can insert the data into SQL table and then you can call the result value in derived column.

Create a Table based on results of a column of data in another worksheet and eliminate null values

To set this up....I have roughly 12,000 rows of data that captures sales detail activity. I have an Excel function in a column to the right of the data that identifies the invoice number based on unique qualifiers (if the transcation meets the qualifier it lists the invoice number and, if not, assigns ""). Of the 12,000 rows of data maybe 50 will qualify. I then need to use the invoice numbers that qualify to pull sales and COGS data for all those invoices that match the qualifying invoice numbers (another explanation is necessary at this point....an invoice that qualifies will be listed twice....once that contains the information that identifies whetehr it qualifies but that row will have no sales data and a second time with thye dsales data...I do not know why it does it this way. So, in other words, the row of data with the sales information I need to capture does not contain the data that allows me to recognize that an invoice qualifies). Each mopnth adds the current month's sales data to the population...so, 12,000 rows this month and it will be 16,000 next month and so on.
I was hoping to create a table that pulls only the qualifuying invoice numbers from the sales data (it would basically create a table of 50 (in my example) while ignoring the 11,950 rows where the cell equals ""). I can do a simple pivot table but next month I need it to recognize the new population of data and update based on the additional rows of new monthly data as well as the rows of data from prior months.
Any soultions/ideas are much appreciated!

MS SQL Server, arrays, looping, and inserting qualified data into a table

I've searched around for answer and I'm not sure how best to frame the question since I'm rather new to SQL Server.
Here's what I got going on: I get a weekly report detailing the products that have been sold and the quantity of each. This data needs to go into a yearly totals table. In this table the first column is the product_id and the next 52 columns are week numbers, 1-52.
There's a JOIN that runs on the product_id of both the weekly and yearly tables. That finds the proper row and column to put the weekly quantity data for that product.
Here's where I'm not sure what to do. In 2019 there are no product_id in that column. So there's nothing to JOIN on. Those product_id need to be added weekly if they aren't there. I need to take the weekly report of product_id and quantity and check each product_id to see if it's in the yearly table. If not I need to add it.
If I had it my way I'd create an array of the product_id numbers from the weekly data and loop through each one creating a new record in the yearly table for any product_id that is not already there. I don't know how best to do that in SSMS.
I've searched around and have found different strategies for this. Nothing strikes me as being a perfect solution. There's creating a #temp table variable, a UNION using exclude to get just those that aren't in the table, and a WHILE loop. Any suggestions would be helpful.
I ended up using a MERGE to solve this. I create a table WeeklyParts to dump the weekly data into. Then I do a MERGE with the yearly table inserting only those where the is no match. Works well.
-- Merge the PartNo's so that only unique ones are added to the yearly table
MERGE INTO dbo.WeeklySales2018
USING dbo.WeeklyParts
ON (dbo.WeeklySales2018.PartNo = dbo.WeeklyParts.PartNo)
WHEN NOT MATCHED THEN
INSERT (PartNo) VALUES (dbo.WeeklyParts.PartNo);

Dealing with repeated fields

I'm storing a log on the server with multiple lists where I store some data such as dates and information associated to these dates. The first field of the first list corresponds to the first field of the rest, the second field of the first list to the second field, and so on.
Using the FLATTEN function I managed to show this information, but it shows a combination of the whole data on the lists. Having 4 lists 3 fields each, generates 12 different rows.
Is there any way to show only three results, by order on the lists?
I don't love this solution, but it's the first idea that comes to mind that solves your problem:
SELECT dates, lead, userID FROM
(SELECT NTH(1, dates) WITHIN RECORD dates, NTH(1, lead) WITHIN RECORD lead, userID
FROM [egolike.com:egolike-production:egotest.egoViews]),
(SELECT NTH(2, dates) WITHIN RECORD dates, NTH(2, lead) WITHIN RECORD lead, userID
FROM [egolike.com:egolike-production:egotest.egoViews]),
(SELECT NTH(3, dates) WITHIN RECORD dates, NTH(3, lead) WITHIN RECORD lead, userID
FROM [egolike.com:egolike-production:egotest.egoViews])
WHERE dates IS NOT NULL
Basically we are mapping the Nth value of a column within a record to the Nth value of the other column. A drawback is the need of explicitly calling each Nth place by number. Hopefully you can re-import the data with a different structure! (One repeated column, containing the aligned records)

Resources