Summarising a Pivot Table by Month Groups - google-sheets

I have a simple table with Monthly downloads data for the last 24 months. I want to build a simple Summary showing the following columns.
Number of Downloads for last Month
Downloads in the last 3 Months
Downloads in the last 6 Months.
Downloads in Last 6 Months (last year)
Downloads in Last 3 Months (last year)
Downloads in Last Month (last year)
I tried to group the data in the pivot table - but I can't seem to get it to work as Google Sheets doesn't allow overlapping Groups.
I tried using Calc fields - but again it doesn't seem to allow me to break it out by months.
Any Idea - how to do this or am I asking too much of Google Sheets?
Added a dummy set of data: https://docs.google.com/spreadsheets/d/1qhuXf__hvJMZjXcugBZyiq_lZBqFNTTkCHEvh9rcUK0/edit?usp=sharing

={QUERY(TRANSPOSE(QUERY(TRANSPOSE({$C$3:$O$5,$C$7:$O$9}),
"select Col2,Col3
where Col1>=date'"&TEXT(DATE(E13,1,1),"yyyy-mm-dd")&"'
and Col1< date'"&TEXT(DATE(E13,9,1),"yyyy-mm-dd")&"'")),
"select Col2+Col3+Col4+Col5+Col6+Col7+Col8+Col9
label Col2+Col3+Col4+Col5+Col6+Col7+Col8+Col9''"),
QUERY(TRANSPOSE(QUERY(TRANSPOSE({$C$3:$O$5,$C$7:$O$9}),
"select Col2,Col3
where Col1>=date'"&TEXT(DATE(E13,9,1),"yyyy-mm-dd")&"'
and Col1< date'"&TEXT(DATE(E13+1,1,1),"yyyy-mm-dd")&"'")),
"select Col2+Col3+Col4+Col5
label Col2+Col3+Col4+Col5''"),
QUERY(TRANSPOSE(QUERY(TRANSPOSE({$C$3:$O$5,$C$7:$O$9}),
"select Col2,Col3
where Col1>=date'"&TEXT(DATE(E13,12,1),"yyyy-mm-dd")&"'
and Col1< date'"&TEXT(DATE(E13+1,1,1),"yyyy-mm-dd")&"'")),
"select Col2")}
demo spreadsheet

Related

Query Function, Timesheet Data Viz

I'm working on a timesheet dashboard for my office. My goal is to create summaries of weekly, monthly and yearly time spent on overhead vs. projects. I have based the formula on Player0's work that organize the data into weekly, monthly, and yearly results (all hours added up). I do not know how to separate overhead work from time on project work. Sample Sheet:
https://docs.google.com/spreadsheets/d/1IRtS60P256_fo-Yen1IKV4U6SkNpZJWc1Cf8Jeqw_20/edit?usp=sharing
Desired Output: Please refer to Sample Sheet, Dashboard tab, for example.
Generating TOTAL HRS should be simple in a Query function, by adding up OVHD HRS + PROJ HRS columns (once created).
Generating % PROJ HRS should be simple in a Query function with basic athematic.
What would we use to generate OVHD HRS and PROJECT HRS as new columns?
Thank you in advance for your insights.
Player0's post: Sort timesheet logged hours by week
I've tried using SUMIF function to create the additional columns within Query, but get an error (number of rows doesn't match...).
The one formula which do everything is here.
put the formula into C2 as shown in the images.
in A3, select in which method do you want to display the results.
in A4, select in which staff do you want to display the results.
This formula mainly uses QUERY() to modify data from the given range, togather with some other date functions.
=ArrayFormula(LAMBDA(SHOW,STAFF,
LAMBDA(RANGES,
LAMBDA(HEADERS,JBRAW,FFRAW,TGRAW,
LAMBDA(DATARAW,
LAMBDA(YEARS,MONTHS,MONTHLY,WEEKS,WEEKNUMS,TYPES,
LAMBDA(DATA,
LAMBDA(SHOWWEEK,ORDER,
LAMBDA(RESULT,
QUERY(IF(RESULT="",0,RESULT),"SELECT Col1,Col2,Col3,Col2+Col3,(Col3/(Col2+Col3)) LABEL Col2+Col3'TOTAL HRS',(Col3/(Col2+Col3))'% PROJ HRS' FORMAT (Col3/(Col2+Col3))'#,##0.00 %'",1)
)(QUERY(QUERY(QUERY(DATA,"SELECT "&SHOW&",SUM(Col6) "&SHOWWEEK&" WHERE Col2='"&STAFF&"' GROUP BY "&SHOW&SHOWWEEK&" PIVOT Col1",1),"ORDER BY "&ORDER,1),"SELECT Col1,Col2,Col3",1))
)(IF(SHOW="Col7",",Col5",""),IFS(SHOW="Col7","Col4 DESC",SHOW="Col8","Col1 ASC",TRUE,"Col1 DESC"))
)(QUERY({DATARAW,YEARS,MONTHS,WEEKS,WEEKNUMS,TYPES,MONTHLY},"SELECT Col10,Col1,Col6,Col7,Col8,Col5,Col9,Col11 LABEL Col6'YEAR',Col7'MONTHS',Col8'WEEKS',Col9'WEEK',Col11'MONTH'",1))
)(
YEAR(INDEX(DATARAW,,4)),
MONTH(INDEX(DATARAW,,4)),
TEXT(INDEX(DATARAW,,4),"mmmm"),
WEEKNUM(INDEX(DATARAW,,4)),
IFERROR("WEEK "&WEEKNUM(INDEX(DATARAW,,4))&" "&YEAR(INDEX(DATARAW,,4)),""),
IFS(INDEX(DATARAW,,2)="PROJECT #","TYPE",INDEX(DATARAW,,2)=0,"OVHD",INDEX(DATARAW,,2)>0,"PORJ")
)
)({HEADERS;JBRAW;FFRAW;TGRAW})
)(
ARRAY_CONSTRAIN(RANGES,1,5),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,1))&" WHERE Col1 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,1)&"''")),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,7))&" WHERE Col7 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,7)&"''")),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,13))&" WHERE Col13 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,13)&"''"))
)
)(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1IRtS60P256_fo-Yen1IKV4U6SkNpZJWc1Cf8Jeqw_20/edit#gid=1822160043","'D_Transpose'!A:Q"))
)(IFS($A$3="Weekly","Col7",$A$3="Monthly","Col8",$A$3="Yearly","Col3"),$A$4))

Google tabs IMPORTRANGE with SUMIF problems

I know it has already been a few times discussed topic, but I haven't found any help that would suit my problem yet.
I'm trying to make a sum of numbers in one column in a different Google sheet. The problem is I need to sum only those numbers happened in chosen month. I have the number of the month in the sheet where I need the function, and I have the month specifikation in a column next to the numbers.
All I came to till now is this (after many totally different codes):
=sum(query(IMPORTRANGE("xyz";"Výkaz!B23:C125");"select Col2,Col3 where "col2=G4";0)"))
G4 is the chosen month I have in the same sheet as this code
Please, could you help me figure this out? Thank you
Google Sheet 1 (TabName = "externalTab")
Google Sheet 2 (TabName = "InternalTab")
Use importrange to pull the all data from "externalTab" to "Internal Tab". Then just use a sumifs formula to add up values based on your criteria.
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/1sLPGZkAVlxWfjhDMU9oa_cww0AI570Rtem0XCoOx0AE", "'externalTab '!A1:AF2000")
Alternatively use the following formula. Integers to be summed are located in column a/Col1 and Months are located in column b/Col2. There is one header row on the spreadsheet and we are adding up all the Integers that correspond to the month June.
=sum(query(importrange("https://docs.google.com/spreadsheets/d/1sLPGZkAVlxWfjhDMU9oa_cww0AI570Rtem0XCoOx0AE","a1:b1000"),"select Col1, Col2 WHERE Col2 = 'June'",1))

How to display a list of days including days without any logged activities in google sheet?

I have made a google form in which I input how much I train and meditate each day and I would like to make a summary of that data so that I can easily how much I have done each day INCLUDING the days where I have done nothing.
I have a working solution but it involves me adding all empty days manually to be able to show them in my summary/status.
Current solution:
Sheet 1: "Form responses 1" - This is where all the data comes in
Sheet 2: "DatesTraning" - This is a list of all days and a 0 (zero) for each day in the column listing how many minutes I have been training. The columns in this manually created sheet is identical to the ones in "Form responses 1"
Sheet 3: "ResponsesAndDates" - This where I combine the data from "Form responses 1" and "DatesTraining" with the following query:
=query({'Form responses 1'!A2:M;DatesTraning!A1:M},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where (Col1 < date '"&TEXT(TODAY() +1,"yyyy-mm-dd")&"') order by Col1 desc")
Sheet 4: "Status" - This is where I summarize/display things with forumulas like this:
=query(ResponsesAndDates!A1:M,"select toDate(K),sum(H) where C='Träna' group by toDate(K) order by toDate(K) desc label toDate(K) 'Datum', sum(H) 'Total tid'")
Column C is a category column (so I can add filtering for more categories of entries)
Column H contains the number of minutes trained
Column K contains the date for the training/meditation
I did this to be able to easily see both the days where things are logged in addition to the days where things have not been logged. Is there a more easy way to do this without the manual step of using the "DatesTraining" sheet?

How to get current weekly closing price of stock in google sheet?

How can I fetch current weekly closing price of a stock in google sheet?
I have tried using the formula GOOGLEFINANCE("GOOG", "price", TODAY(), TODAY(), "WEEKLY").
But its showing no results.
=GOOGLEFINANCE("NASDAQ:GOOGL", "close",TODAY()-60,TODAY(),"WEEKLY")
You can adjust the TODAY()-60 to a start date DATE(2019,1,1) for example:
=GOOGLEFINANCE("NASDAQ:GOOGL", "close",DATE(2019,1,1),TODAY(),"WEEKLY")
or how you'd like to do it. It might update the current week in real time if you use "price" instead of "close", not sure since it's the weekend, and so nothing is ticking or updating right now.
Since it appears you just want a single result of the most recent weeks closing price, try this:
=INDEX(GOOGLEFINANCE("NASDAQ:GOOGL","price",TODAY()-14,TODAY(),"WEEKLY"),3,2)
Improved the integer for the one above, but it could still theoretically break.
Try this instead, as it gives a 30 day range but only selects the result from within 1 week:
=INDEX(QUERY(GOOGLEFINANCE("NASDAQ:GOOGL","price",TODAY()-30,TODAY(),"WEEKLY"),"select Col2 where Col1 < date'"&TEXT(TODAY(),"yyyy-mm-dd")&"' and Col1 > date'"&TEXT(TODAY()-7,"yyyy-mm-dd")&"' limit 1"),2)
Hope that (finally) helps!

Need help creating a formula for dynamic average of last 4 weeks expenses

I am looking to create a spreadsheet that my staff fill out, it then gives me a master sheet with all the data, then I import dynamically to my financial spreadsheet telling me the average cost of my client over the last 30 days.
I am looking to create an AVERAGE formula of the last 30 days when Date = Today (Monday) (I want the weekday Monday as that's when staff hand in invoices)
Hope this makes sense, it's really tough!
Here's a video of me explaining my desired outcome
https://www.loom.com/share/3a9cb75052b246d1af2ba2f9ce9180a7
I've followed several guides & can't figure it out.
=ArrayFormula(iferror(query(average(if(today() - weekday(today(),3)-30)))))
I expected $90 average and I just get blank
You could use this formula:
=AVERAGE(VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)+1,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-6,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-13,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-20,A:H,2,FALSE))
To break it down in to its component parts, the AVERAGE is taken from VLOOKUP results:
VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)+1,A:H,2,FALSE)
The VLOOKUP is looking for the last Monday from the current date:
TODAY()-WEEKDAY(TODAY(),2)+1
Then
TODAY()-WEEKDAY(TODAY(),2)-6
and so on...
When using on your sheet, you will have to specify the column you want to reference in your look up, for colunm B (brand1) use: A:H,2,FALSE), for colunm C (brand2) use: A:H,3,FALSE), for colunm d (brand3) use: A:H,4,FALSE) and so on...
=INDEX(QUERY({INDIRECT("A2:D"&ROW()-1)},
"select avg(Col2),avg(Col3),avg(Col4)
where Col1 <= date '"&TEXT(TODAY(), "yyyy-MM-dd")&"'
and Col1 >= date '"&TEXT(TODAY()-30, "yyyy-MM-dd")&"'"), 2, )

Resources