Query that returns results that are at least a week apart - sql

I have a google sheets spreadsheet that has lots of user data, timestamped. This data is entered into the google sheet by administration AND end users via a google form, so the data points don't come in at regular intervals. I want to be able to query against this datapool, but limit the results shown based a defined amount of time between result.
So say I wanted to query for Bob, I would get 3 results. Is it possible to query this data in a way that it would see the 11\11 result, but disregard the 11\12 result becuase it's within a week of the previous result? Really I'd like to be able to do this for any timeframe.

Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.

Related

Compare Dates in a column corresponding to Changes in an other row

I have a large sample of medical data I need to try and analyze patterns in Excel worksheet.
I also put them up in a database in MS ACCESS to do my first filters and stuff.
I have the infos of patients, with tests results(POS or NEG), dates of the sample.
I need to be able to check for each patients when the results change from POS to NEG and from NEG to POS
and compare the dates of those two samples.
So far I was doing it manually which isn't viable for my sample.
I was trying to do something in SQL, but that didn't work out for me.
I also am trying to do some VBA or Excel formulas but I admit I'm getting kind of stumped.
I know I should do some for each cell loop or something but I really am lost.
I already grouped each patients info together using sub-totals and stuff.
Your help or at least pointers would be greatly appreciated :D
Here's an example of my data.
enter image description here
Use a formula like this, that in case the name is the same as the row before and the POS/NEG is different from the row before gives you the number of days in between, blank otherwise:
Of course it will give you an error if you try to use it on the 1st line, just enter it in the 2nd line and copy/paste in all the rest.
This should give you the basis for the rest of your analysis.

VBA - Graph by month

I am having issues trying to create code to make a graph that is dependent upon months. So I have Column A which is the beginning of the week date, i.e. 1/1/17. In Column B I have the count from that week of issues occurred. I would like to group together the count by month, using the Month function, so for January there are 37 issues, February - 23, etc. And then make a graph accordingly where the first month is titled January.
Eventually, I would like to similarly do this on a quarterly basis as well, but any help with the monthly issue first would be greatly appreciated. Here is a screenshot of the data which is located in Worksheets("Report").
First off, format your data as a table since that will make your life much easier. You will need to add headers to each column. This will make your data easier to read, and easier to maintain.
To format it as a table highlight the range, and then press CTRL+T. Make sure to check 'My data has headers'.
Good, now click inside the table, Insert > PivotTable. Select the destination. For rows you want Date, for values you want Sum of Value (where value is whatever you name your values column.
Then finally, check out this article for the whole rundown of Groupby: http://www.contextures.com/xlPivot07.html.
To be fair, there is an easy enough way of doing this without a PivotTable (adding a helper column for Month for example), but there's no need to reinvent the wheel. Additionally, if you want to add Qtr. eventually, you're better off familiarizing yourself with workhorses of excel.
Lastly, once you have taken the above steps, you'll likely find the Timeline slicer very helpful. You can use that to visualize specific periods on your pivot or chart.
Minor Note: This all assumes your dates are true dates. If they aren't, you'll likely run into more issues.

Merging cells horizontally across twelve columns

I am trying to merge cells horizontally, and I understand it can't be done dynamically by expression, so I'm looking for suggestions on a possible alternative way to accomplish it. I have 3 columns of data and then the next 12 columns are months. They enter the start month and then it's a rolling twelve month display. The user want's the top row of the heading to be the year, but merged. The second row of the heading is the month name. I've suggested to the user the easy task of merging after the export, but she also wants it exported to PPT and be ready to publish without modification. Any ideas?
enter image description here
This may seem like pretty simple stuff to you veterans, but I'm new to SQL and SSRS. So, to answer my own question, I ended up creating 12 rows that I can make visible according to the starting month of the rolling 12 months. I wasn't sure how that would work, but it is working great and I now have a foundation if I ever need it again.

Excel Macro to combine cells of data when data matches in another column

The best way I can explain my problem is by showing a few screenshots.
I need to turn data like this:
[
Into something that displays like this:
After Data
There are multiple part numbers in the file, and I need the macro to take all the data from a matching part number and transform the data into what is displayed in the second image. All the part numbers are grouped with their data together, so it wouldn't need to run the loop through the top every single time, but adding to the entries with each new piece of data. Something also needs to be done for the years as well, because the way the data is presented, is in a range of years, and I need an entry for each year in that range.
Additional Information:
I am using this data for prep for category data for a BigCommerce site, that is working with a year/make/model plugin on the site, to create a vehicle lookup system. Thus in order for the user to look up their vehicle accurately the categories need to be listed the way they are in the second picture, which needs to be the result of the macro.
I thank anyone who takes the time to look into this, it will cut down the time I spend doing this manually by a huge amount.
You can do this with a formula (without actual VBA):
In cell F2 write: ="YMM/"&C2&"/"&D2&"/"&E2&";"
In cell F3 write: =F2&"YMM/"&C3&"/"&D3&"/"&E3&";"
drag down the formula in F3 until the last row.
The last row will contain the entire string of all vehicles.
I just noticed you may have duplicate values. You can use the built in Remove Duplicates feature to remove those before using the above technique.

Im trying to populate a Sharepoint list with the most upcoming dates from certain colums of data from another Sharepoint list?

I have a list named Employee Dates, this list contains the columns:
Employee | CPR Completed | CPR Required | ETC
These columns keep going on for all of the training courses required for our employees with alternating columns for completed and required dates. I am using a workflow to calculate all of the required dates of training from the completed dates.
What I desire to do is make another list that will look at ALL of the columns for the required dates and find the soonest ones and populate that list with the soonest dates and from which column it was pulled from.
Any help as to how to approach this? I have been trying to use queries in Access and also some of the custom view settings in SharePoint Designer but no luck so far.
You could try an Excel table (they also have these functions in access if I recall, but I avoid access like a plague). To connect Excel to share point follow the steps in this article:
support.office.com
Ok, now that we are connected you should see all of the columns and values in excel. Next up we need to find the min date (easy) and then get the associated column name (a little harder).
Min Date: The formula should be something along the lines of =min(B1,B3,B5), jut type in =Min( and then CTRL-click on the columns you want to consider for the row. When your done close with ). After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows.
Column Name: A little more difficult, use the min value from the prior column as the lookup value for VlookUp to get the column name. After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows. I'd explain VlookUp, but I'd run out of characters and attention span long before I got to the relevant parts, and excel functions does a fine job of getting you the basics.
Anyway hope that helps,