I have a dashboard that I'm creating, And it contains start and end dates, which I want to split out into months (which I'll group together later in order to create charts etc)
I'm not sure if this is possible but if I data like this (simplified for query purpose):
And I basically want to split the data like this:
I can achieve this with a script that I've written which the user can run by clicking a button. I was just curious if it's possible to achieve this using formulas (I'm fine with writing scripts, but still struggle with query and array formulas) since this is for a dashboard, I thought it would be nicer if the data updated "live" instead of having to click a button.
use:
=INDEX(TEXT(QUERY(SPLIT(FLATTEN(IF(A2:A="",,A2:A&"×"&IFERROR(TEXT(DATE(YEAR(B2:B),
MONTH(B2:B)-1+IF(""=SPLIT(REPT(12, DATEDIF(EOMONTH(B2:B, -1), EOMONTH(C2:C, -1)+1,
"M")+1), 2), "♀",COLUMN(1:1)), 1), "mmm yyyy")))), "×"),
"where Col2 is not null"), {"#", "mmm yyyy"}))
This is not an elegant answer but it does the work done by modifying an answer here
Formula:
=arrayformula(SPLIT(A4&";"&unique(text(sequence(days(C4,B4)+1,1,B4), "MMM YYYY")), ";"))
Output:
Note:
I have 3 cells with formula here (E2 for Project A, E9 for Project B and E13 for Project C).
You will need to change A2, B2, and C2 to their respective cells for every entry.
Regarding the manual clicking of a button on your script, I do recommend that you use onEdit trigger with your script instead to automatically trigger the script once a certain cell is edited (or a certain condition is met). That way, no buttons will be needed to be clicked.
Related
I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)
I want to use arrayformula or filter like with the result of a list of numbers. My question is how to place at the bottom a total of the preceding numbers. The challenge is this is dynamically sized. So when I try to include an option to sum the numbers it doesn't work.
What complicates this even further I would then want to include some numbers below this that aren't included in the sum.
What I tried was this:
={"title"; ArrayFormula; sum of previous cells}
Projects
Title
P1
1
P2
2
P3
1
P4
2
Total
6
Edit: An example that I've used that didn't work out is this:
={arrayformula(if(filter($A2:$A,$A2:A<>"",$A2:$A<>"Total Sum",$A2:$A<>"(to be hired)")="","",{countifs('org 1'!$F$2:$F$1000),"="&filter($A2:$A,$A2:$A<>""),'org 1'!$A$2:$A$1000"),"<>(to be hired)")}));"Total hired"}
Edit:
Here's an example link:
https://docs.google.com/spreadsheets/d/1iBkX1B53vYQVUJ6j8dNOE_ck1dONidsqyNuO0lgSKHw/edit?usp=sharing
I'm using multiple tabs as a reflection to what I'm working with. The tab everything's suppose to show is the Indirect example tab.
I'm using the Source tab as a reference for the tabs I'm targeting. The data tabs is the place I'm drawing the info from.
I'm thinking that I won't be able to do this with ArrayFormula. Probably with Query instead. Not sure what it would look like. If ArrayFormula won't work then a query example would be nice.
see:
={"title"; FILTER(A:A, A:A<>""); SUM(A:A)}
={QUERY({A1:B}, "where Col1 is not null label Col2'title'"); "Total:", SUM(B:B)}
I have some entries against days of the year:
I want to state the average of these entries for every week (hence the week helper column in Column A).
Normally to do this I would use FILTER:
AVERAGE(FILTER(C:C, A:A = A1 ) ))
Where A1 is the week number against which I would like to place the average (assume that this is on another tab and correctly referencing the data).
This works for a single cell, and if I drag the formula down manually. However, I want it to update automatically, but I cannot use ARRAYFORMULA with FILTER. I am not sure of the solution: the other questions on SO can be solved more easily as they do not require multiple rows to be returned. I do, so I cannot use VLOOKUP, which would solve the problem.
in a new cell, on a brand new tab, try this assuming the tab name with the data is "Sheet1":
=QUERY('Sheet1'!A:C,"select A,AVG(C) where A<>'' group by A")
Here is a good resource on QUERY().
I have a spreadsheet I am entering information from a fundraiser in. I have many parts of it done and it seems like what I'm running into should be easier. I have 3 rows set up for each fundraising program, the first row contains a few pieces of incidental information and then a series of dates/times/dollar amounts. I need to search through this range for every dollar amount that came in at, for example, 7:00 am and add them together. I would like this list to come in starting at L1 in the sample sheet and correspond to the list of times in column K.
I will also need to total all the contributions based on a topic which is the cell under the title of the program - but I should be able to figure that out once I move on to it.
A sample sheet is here: https://docs.google.com/spreadsheets/d/1Kg7XhIgzI0o0uIuGg0RTzv7j_bne8pk6DUwSecIXa9E/edit?usp=sharing
I have tried a variety of formulas using ArrayFormula, VLOOKUP, and filter. I've found examples online using each of those functions that seemed like they should work but didn't. One stopped at the first result it came to and another looked like it was creating a list of what it was found in the cell instead of adding them together.
My current unsuccessful code is:
=vlookup(K1, $H$46:$J$164, 2, 0)
This appears as if it is stopping after encountering the first 0. It's definitely not adding in cell I50
I expect the results for 7:00 am to be $406 but I get $0.
paste in L1 cell:
=ARRAYFORMULA(IFERROR(VLOOKUP(TO_TEXT(K1:K35), TO_TEXT(QUERY({
FILTER(H46:I, MOD(ROW(INDIRECT("A4:A"&ROWS(A46:A)+3)), 4)=0);
FILTER(K46:L, MOD(ROW(INDIRECT("A4:A"&ROWS(A46:A)+3)), 4)=0);
FILTER(N46:O, MOD(ROW(INDIRECT("A4:A"&ROWS(A46:A)+3)), 4)=0);
FILTER(Q46:R, MOD(ROW(INDIRECT("A4:A"&ROWS(A46:A)+3)), 4)=0)},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''", 0)), 2, 0), 0)*1)
I've been trying to use Google Sheets Query to find the more recent data of a particular name while pulling the rest of the data from the row. And having not luck.
This is a sample of what the Raw Data looks like:
And this is the output that I would like to achieve:
The closest I got to the output that I need is
=QUERY('Raw Data'!A:F,"select max(A), B, C, D, E group by B, C, D, E",1)
But the most important data is in F. When I add in F to 'select' the formula breaks, so I also grouped by F. Then that also pulls in the 4/1/17 data for Mark.
Anyone know whats going on? Or have a better formula for me to work with?
Thanks!
As far as what is going on, I worked with your formula and it picked up the extra date for Mark even before I added column F. As I understand it, if you want the max date per person, you really need =QUERY('Raw Data'!A:F,"select max(A),B group by B",1)
I put that in A1 in the worksheet I was using (not the same as the raw data one). So in its column A and B, I now had the maximum date and the person's name. Next to the first date, I put in column C the following formula, then dragged it down. I was simplifying to do just dates, but I believe it could be adapted to handle times if needed (if the person does multiple times a day and you want only the latest).
="'"&text(A3,"yyyy-mm-dd")&"'".
This gave me the date in single quotes, which I then used in column D, that built up the where clause, with the following formula in the first row,="(A=date "&C3&" and B='"&B3&"')" and the draggable formula =D3&" or "&"(A=date "&C4&" and B='"&B4&"')" in each subsequent row.
In the example with 3 people, the last clause ended up in D5 for me, so my final query was=QUERY('Raw Data'!A:F,"select A,B,C,D,E,F where"&D5,1), and that generated the desired results. My hesitation about this answer is whether it will scale, or whether it will too quickly hit a limit on length of the where clause.