How to increment date in arrayformula sumifs in google sheets? - date

I have adapted a formula from another post and it works, yet I need to increment the formula down hundreds of rows, but I cannot figure out how to get the dates to increase.
I have a Google Form that sends data to its spreadsheet. There may be several entries per date and I want the data to be summed on the 2nd sheet before I graph it.
Data
A B
6/3/2016 06:06:00 2
6/3/2016 11:06:00 2
6/4/2016 07:05:00 1
6/4/2016 09:10:00 5
Result
A B
6/3 4
6/4
B2 =ArrayFormula(SUM(If((Data!A$2:A<DATE(2016,6,5))*(Data!A$2:A>DATE(2016,6,4)),Data!B$2:B)))
I will have dates that run the entire year, so I need an easy way to increment the dates. Also, if you have a way to grab data from the exact date needed, that would be nice too (instead of giving the date range).

A query formula may work better in this example, such as:
=QUERY({ARRAYFORMULA(TRUNC('Form responses 1'!A2:A)),'Form responses 1'!B2:B},"select Col1,sum(Col2) where Col1 >0 group by Col1 label Col1'Date' format Col1 'mm-dd'")
Amend the sheet name and ranges as appropriate

Related

Google Sheets - Expanding dataset according to months between 2 dates

I would like to be able to expand a dataset to include one row per "person" per month, filtered by Start and End Date.
Consider the example below:
This is the desired outcome
Inputs are a start and end date, which could be anywhere between the start of a given financial year (01/04/20XX) and the end of that financial year (31/03/20XY).
The output rows contain each month comprised between these 2 dates for which there is a matching entry in the input (see example output)
I have an example sheet here.
Any help would be appreciated, thanks
Try:
=ARRAYFORMULA(SPLIT(UNIQUE(QUERY(FLATTEN(IF(DAYS(C2:C4,B2:B4)>=SEQUENCE(1,1000,0),A2:A4&","&TEXT(B2:B4+SEQUENCE(1,1000,0),"YYYY-MMM")&","&D2:D4,"")),"where Col1 is not null")),","))
Result:
This works however the only limitation is you have to manually edit the formula to specifically define the End range. It crashes when I set it to use the whole column using the formula below:
=ARRAYFORMULA(SPLIT(UNIQUE(QUERY(FLATTEN(IF(DAYS(C2:C,B2:B)>=SEQUENCE(1,1000,0),A2:A&","&TEXT(B2:B+SEQUENCE(1,1000,0),"YYYY-MMM")&","&D2:D,"")),"where Col1 is not null")),","))
I am assuming this is because of the Query function which runs a Google Visualization API Query Language query across data making it very long and heavy processing.
Explanation:
To explain how this works using the formula from this link: Google sheets - List of dates between a list of start and end dates to get the dates between, but I changed the IF to return all combined 4 columns. Converted it to date format using TEXT (YYYY-MMM). I then used the UNIQUE to remove duplicates so it will only show the months. Then make use of SPLIT to split across 3 columns.
References:
Get dates between 2 dates
TEXT
UNIQUE
QUERY
SPLIT
Hope this helps!

How to MATCH Dates in separate Columns and then SUM all values for a specific Date? (Google Sheets)

I am trying to create a stock portfolio tracker.
Table 1 has all transactions in this format: Date | Irrelevant | Amount Bought (+) or Sold (-).
Table 2 has all Dates for every Day from the Date of the first purchase until the current Date.
Table 1 Table 2
I am trying to get a Formula that calculates the total amount of shares bought/sold on a given day. Table 2 should then look like this:
Goal (A) Goal (B) Goal (C)
I have tried some array formulas but cant figure out how SUM all Amounts for a specific Date.
This is what I currently have:
=ArrayFormula(INDEX(Transactions!$B$12:D, MATCH (TRUE,EXACT(Transactions!$B$12:B, B7),0)))
I am thankful for any help!
I believe this isn't really a proper question for stackoverflow, but try `=SUMIF(Transactions!$B$12:$B, B25, Transactions!$D$12:$D)' and just drag it down (or Ctrl+D).

Tableau measure count items if between dates

What I am trying to achieve is to get a count of people employed in a particular period.
I have 3 variables:
Employee ID (integer)
Hire date (date)
Termination date (date or null)
Example
the formula I am looking for is something like
if termination_date is null
then
count employee_ID in
dates between Hire_date and max of either hire_date or termination_date
else
count employee ID in
dates between hire_date and termination_date
This aims to show the dynamic of staff level over the time.
I am new to Tableau, not sure how to even start with it. Any suggestions welcome.
This problem will be simpler if you reshape your data to have the following three columns
Employee ID
Date
Action. (where action takes on the values of ‘Hire’ or ‘Terminate’).
Each data row represents one change in status for an employees. If an employee had a termination date, they will have two records in this new format, otherwise just one record showing the hiring date.
You can reshape your data by hand, or leave the original and use Tableau Prep or the Tableau data source page to reshape using a self Union and a few simple calculated fields.
Define a calculated field called Staffing_Change as
if Action=‘Hire’ then 1 else -1 end
Now you can plot the change in staff level over time by putting exact date on columns and sum(Staffing_Change) on Rows. You can use a quick Table calc, Running Sum, to see the net staffing level. For line mark types, I’d use a step style by pressing on the path button on the Marks card. Otherwise, the chart can give the impression of fractional number of employees.

How to output Tick Box Grid Responses from Google Forms to Google Sheets as Separate Columns (plus calculates Timezone)?

I need something where our Team Members can select their regular Hours of Availability during the week, in 1 hour intervals, and the results of all Team Members can be seen in a Spreadsheet (and if they fill it out 2 or more times, it will just update their last response). From there, selecting Meeting Times where specific Members can meet should be a lot simpler!
It occurred to me recently that Google Forms and Google Sheets could be one of the best solutions here! But I really don't have much experience with Google Apps Script (which it looks like I'm going to need to do what I want it to do), and so I have some questions:
I have a 7 x 24 (7 Days of the Week by 24 1-Hour Intervals) Tick Box Grid (see linked image here). How can I set it up so it can output each Row+Column in its own separate Column in the output Google Sheet (see linked image here for my preferred output for a single Day)?
In case you're wondering what is going on with the 3rd Row: I have SUM Functions =iferror(counta(L4:L62)) (where L is the Letter of the Column) to Total the "Checked Responses" in each Column for an easy glance of the number of Xs (Yeses) for each Hour Block Column.
How can I customize each Row+Column Checked Response so it outputs as a simple letter X?
I also have a Dropdown Timezone Question, where it asks the User select their Timezone from 1 of the 25 available Timezones in the world. I would like it so their responses to the Hours of Availability Tick Box Grid is modified to match their responses in GMT. So for example, if I select my Timezone as GMT -4, and in the Tick Box Grid I select 12AM to 1AM on Sunday, the Google Sheet will include an X under 7PM to 8PM on Saturday?
Am I asking for too much from Google Forms + Google Sheets API here? And if I am, maybe there is a better Cloud Program I could use for handling this?
So #MattKing (Matthew King) worked closely with me yesterday to get my Tick Box Grid to output to Google Sheets as I intended, as well as handling Timezone Conersion! You can see the Test Results in here:
https://docs.google.com/spreadsheets/d/1g5S5Nyfwr8eHWyn-UXVfdbVj8tdZeY-lU20C2VxuCZ8/edit
I should first mention that the Form Output Sheet (called Form responses) should NOT be modified. Also NO Google API Scripting has been required to get Google Sheets to format the Form Results as I want to. Instead, new Sheets with Formulas (rather complex ones might I add) was the way to go!
To output 1 Hour increments of 24 hours for 7 days: =ARRAYFORMULA(SEQUENCE(1,24*7,0)/24+1)
Each Name in "Form Responses" (in Column A) can be output, in alphabetical order, as follows: =QUERY({'Form responses'!B2:C},"select Col1 where Col2 is not null order by Col1")
Hours of Availability in "Form Responses" (in Columns E through AB) can be output (where each Column is 1 of 24 hours in 1 of 7 days) as follows: =IF($A4="",,IF(ISNUMBER(MATCH($A4&TEXT(B$2,"ddd hh"),UTCData!$A:$A,0)),"X",))
If I want to have separate Meetings in separate Sheets, and I have the Meeting Name (selected as Checkboxes in the Form) in A1, then I can set it up so only the Names of the People who checked that Meeting will be shared as follows: =QUERY({'Form responses'!B2:C},"select Col1 where Col2 Contains'"&A1&"' order by Col1")
He also created for me 2 Sheets that handle more Formula Conversions:
Flattened Form Sheet
Flattened Formula: =ARRAYFORMULA(QUERY(SPLIT(FLATTEN('Form responses'!B2:B&"|"&'Form responses'!C2:C&"|"&'Form responses'!D2:D&"|"&MID('Form responses'!E1:AB1,64,20)&"|"&'Form responses'!E2:AB),"|",0,0),"where Col5<>''"))
Extract Times: =ARRAYFORMULA(IF(D2:D="",,SPLIT(MID(D2:D,2,LEN(D2:D)-2)," to ",0)))
UTC Conversion: =ARRAYFORMULA(IFERROR(MOD(MATCH(SPLIT(E2:E,", ",0),TITLE!C10:I10,0),7)+F2:F+C2:C/24))
UTCData Sheet
Name&UTCDayTimeCombos: =ARRAYFORMULA(QUERY(FLATTEN(IF('Flattened Form'!H2:N="",,'Flattened Form'!A2:A&TEXT('Flattened Form'!H2:N,"ddd hh"))),"where Col1<>''"))
In Column C2 - C8, it lists Sunday through Saturday
If you need someone to help you with your Google Sheets and Forms, I can't recommend Matt's help more!

Calculated Field to Sum Two Values Tableau

Is there a way to sum up two values from two different sheets. I have one sheet that looks at full time students as a distinct count of their ID and on another sheet I made a calculated field that takes the contact hours of part time students and divides by 12 (FT course load). I want to be able to add up these two numbers so that the... SUM(Full Time + (Part Time Contact Hours/12)) = ### and would result in an FTE (full-time equivalent enrollment).
Try a calculations similar to these:
Full Time
IF [Type]="FullTime" THEN [StudentId] END
Part Time
IF [Type]!="FullTime" THEN [Hours] END
FTEs
COUNTD([Full Time]) + SUM([Part Time])/12
Obviously I don't know your data structure, hopefully that gives you enough to go on to start.