Want to compute this in google sheet app script between time and dates automatically - sourceforge-appscript

I am making a google sheet file about computing time and dates.
At row 1, if there is Date Update and Time Update, subtract it at Date Downtime and Downtime.
At row 2, if data at Column C, D, E and F are missing do not compute.
At row 3, if there is data at Column C and D, and Column E and F has no data compute it at Current Date and Time.
An app script that can run at google sheet.

Related

Format change when transferring data from excel to Big Query

In excel, I have a column labeled ride_length which has data from 2 different columns that include timestamps (end time - start time).
Example values: 0:06:40, 1:48:08, 34:56:57
I formatted these cells as TIME 37:30:55
After uploading the data to Big Query, the data is formatted as STRING and not time.
What am I doing wrong?
To calculate the duration in Excel to a value with the unit secounds, use this formula
=(A2-A3)*24*3600
BigQuery can parse a string to tranform it to a value. However, the time can be a maximum of 24 hours. Therefore, I would tranform the duration in a value with the unit secound.
Select A,
#time(parse_timestamp("%H:%M:%S", A)) as time_h_less_24,
3600*cast(split(A,":")[offset(0)] as int64)+TIME_DIFF(time(parse_timestamp("%Y:%M:%S", A)),"0:0:0",SECOND)as duration_in_s,
TIMESTAMP_MILLIS(1000*3600*cast(split(A,":")[offset(0)] as int64)+TIME_DIFF(time(parse_timestamp("%Y:%M:%S", A)),"0:0:0",MILLISECOND))
from
(Select "23:56:57" as A)

Microsoft Access- How to create dynamic variables that queries a selection of Columns

Example Data Picture
My main data table is constructed in the following way:
1.State
2.Product
3.Account Name
4.Jan-20
5.Feb-20
.
.
.
N.)Recent Month- Recent Year
My goal is to get 6 total sums based on 6 different contiguous that are user selected. For example, if someone wanted the value of an Account Given a State and Product for FY-2020, they would sum columns 4 to column 15 (Twelve Months).
I am going to be running joins and queries off of the State, Product, Account combinations (first three columns), but I need to create a method to sum the Data table given a list of Column Numbers.
At this point, I am not looking to put non-contiguous columns in a selected Time Period (i.e. all time period selections will be from Col.Beg_TPn to and including Col.End_TPn). The Data Table houses monthly data that will have one new column every month. The Column Number should stay consistent as we are not looking back further than FY-2020.
This a much easier problem in Excel as you can do a simple SumIfs with an Index of the Column Range as the SumRange and then you filter on Columns 1,2,3. My data table is about 30,000 rows, so Excel freezes on me when could calculations and functions on the entire data set.
What is the best way to go about this in Microsoft Access? Ideally, I would like to create a CTE_TimePeriodTotals that houses the First 3 Columns (State,Product,Account) and then 6 TP Columns (tp-1,tp-2...) that holds the sum of each time period for each row based on the Time Period Column Starts and Time Period Column End.

How to set the value of a cell depending of 2 other criteria

I have an Excel tab like this.
It give me information on when a worker is plan to start on a product.
The Columns of my input Table are:
Product Number, Dummy column, Dummy column, Worker ID, Starting Date, Ending Date
The lines in my input Table are:
Product 1,xyz,xyz,Worker 1,13/08/2018 13:50,20/08/2018 15:30
Product 1,xyz,xyz,Worker 2,08/08/2018 03:50,16/08/2018 08:30
Product 1,xyz,xyz,Worker 9,23/08/2018 08:08,03/09/2018 10:00
Product 2,xyz,xyz,Worker 4,10/08/2018 13:50,27/08/2018 15:30
Product 2,xyz,xyz,Worker 9,18/08/2018 03:50,20/08/2018 08:30
Product 3,xyz,xyz,Worker 2,13/08/2018 08:08,13/09/2018 10:00
My Result table should have:
one line per Worker
one Column for each day of the year
The values in the Result Tab should show for a given Worker and a Given Date on which Product the Worker started to work.
So the cell could be empty if at this date the workerX didn't start to work on a product.
Do you have an idea how I can solve this in Excel (or Access if not possible in Excel)?
Access is probably going to be your best bet. You will want to create a column that strips the time value from the Starting Date column, leaving you with only the day value. Let's call that the Starting Day for now. Now create a crosstab query based on your table. The rows will be based on the Worker ID column. The columns will be based on the Starting Day column. The value will use the aggregate function called "First()" on the Product Number field.
I think it should look something like this in SQL (replace <YOURTABLE> with your table name):
TRANSFORM First([Product Number])
SELECT [Worker ID] FROM <YOURTABLE> GROUP BY [Worker ID]
PIVOT [Starting Day]
Good luck!
Transfer your data in column A.
In cells C2 to C20, type the names of the workers Worker 1, Worker 2, etc, in the same way as it is present in the data.
In row 1, enter the dates, starting from cell D1.
In my example, cell D1 is 7 Aug 2018, E1 is 8 Aug 2018., …
In cell D2, enter the following Array Formula
=IF(MAX(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0))=0,"-","Yes")
Array Formulas are entered using Control + Shift + Enter, instead of Enter.
Drag the formula to the required cells.
The result will be "Yes" if a worker has started a project on a particular date, and "-" if no project has been started by a worker on a particular date.
Change the cell references as required.
In place of "Yes", if you want to get the Product details as the result, then use the below Array Formula in cell D2.
=IFERROR(LEFT(IF((MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-")))=0,"-",INDEX($A$1:$A$1000,(MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-"))),1)), FIND($C2,IF((MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-")))=0,"-",INDEX($A$1:$A$1000,(MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-"))),1)),1)-2),"-")
Do let me know if this is what you wanted to do.
Regards,
Vijaykumar Shetye,
Spreadsheet Excellence,
Panaji, Goa, India

Calculating the rolling exponential weighted moving average for each share price over time

This question is similar to my previous one: Shifting elements of column based on index given condition on another column
I have a dataframe (df) with 2 columns and 1 index.
Index is datetime index and is in format of 2001-01-30 .... etc and the index is ordered by DATE and there are thousands of identical dates (and is monthly dates). Column A is company name (which corresponds to the date), Column B are share prices for the company names in column A for the date in the Index.
Now there are multiple companies in Column A for each date, and companies do vary over time (so the data is not predictable fully).
I want to create a column C which has the 3 day rolling exponential weighting average of the price for a particular company using the current and 2 dates before for a particular company in column A.
I have tried a few methods but have failed. Thanks.
Try:
df.groupby('ColumnA', as_index=False).apply(lambda g: g.ColumnB.ewm(3).mean())

Query events for the current week / day

I am tying to use the query function in a Google spreadsheet to extract only the current weeks events.
Column B is a date like '8/19/2014' with the column formatted as a date.
To start off with I am trying to just get the current days events I am not sure why neither of the below statements are working.
=query(A:C,"Select A,B WHERE B = CURDATE()")
or
=query(A:C,"Select A,B WHERE B = TODAY()")
Again my ultimate goal is to take this a step further and show only the events for the current week.
OK, I figured out the formula for extracting the current day:
=query(A:C,"Select A,B WHERE day(B) = day(now())")
Now I just need to figure out how to make it show the current week.