FORECAST formula needed - google-sheets

I have this spreadsheet with some data in column A - Date, column B (keyword usage on a specific date in 2012) and in column C (keyword usage on a specific date in 2013), as it is shown on picture:
What I would like is a function like FORECAST which would "predict" the value for the future date, in this case for February 22 (C5), based on this data.
Can you please help me with the formula?

You can use the =FORECAST(value, data_Y, data_X) formula.
value is the known value for which you want to predict the corresponding forecast (in your case B5);
data_Y is the series of data points for which you want to predict the future value (C2:C4);
data_X is the series of corresponding data points which form the basis of the forecast (B2:B4).
So in your example the formula you would put in C5 is =forecast(B5,C2:C4,B2:B4) which will return 28.7
You can find all formulas and their explanations for Google Spreadsheet at https://support.google.com/drive/bin/static.py?hl=en&topic=25273&page=table.cs

Related

is there a function to get mean values of a column for every unique date in date column?

jupyter notebook screenshot showing al columns in the datasetI have an AQI(Air Quality Index) dataset for which there are various columns such as O3, SO2, PM2.5,etc and a datetime column which has timestamps in it like (20-Sep-2017 - 01:00, 20-Sep-2017 - 00:00). I want to get mean value of columns for every unique date such as O3 has several values but I want only mean for 20-Sep-2017. I've tried regex, and many other things but did not get desired output.

In Google Sheets, how to check if Cell A (Date) is within the Date range of Cell B and C

I have a sheet with a timeline that shows a month per row in column A and an amount in USD next to that month in column B.
I want to be able to specify amounts in column G with a start and end date for that amount in columns E and F.
What I am trying to achieve is that the values in column B are automatically calculated by looking at the start and end dates specified in columns E and F and then taking the corresponding value from column G if the date in column A falls in between the date range specified in E and F.
I have found many suggestions for similar problems online but wasn't able to get any of them to work for my specific case. Any help is very welcome
You could do it as an array formula like this:
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("`E3:E"&count(E3:E)+2)),"YYMM"))*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))*transpose(indirect("G3:G"&count(G3:G)+2)),(INDIRECT("G3:G"&count(G3:G)+2)+2)^0))
The idea is to develop a 2D array where the rows are the months and the columns are the amounts for matching time periods. Then use the standard Mmult method to get the row totals of the array.
Using indirect for the ranges makes the formula longer but using full-column references would be slow as it would result in a nearly 1000 X 1000 array for a default-sized sheet.
EDIT 1
Or shorter
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("E3:E"&count(E3:E)+2)),"YYMM"))
*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))
,INDIRECT("G3:G"&count(G3:G)+2)))
because you can combine the row totals step with multiplication by column G.
EDIT 2
Alternatively you could just employ a much simpler pull-down formula using SUMIFS:
=ArrayFormula(sumifs(G$3:G,eomonth(E$3:E,-1)+1,"<="&A2,F$3:F,">="&A2))
This uses Eomonth to change all the start dates to the first of the month so they can be compared to the dates in column A correctly. The formula still has to be entered as an array formula because of the Eomonth calculation.
Note
The equivalent pull-down formula to the original array formulas above would be
=ArrayFormula(sumifs(G$3:G,text(E$3:E,"YYMM"),"<="&text(A2,"YYMM"),text(F$3:F,"YYMM"),">="&text(A2,"YYMM")))
but this gives zero for all rows - the reason for this is not obvious to me at time of writing.

Sheets Formula - ArrayFormula and CountIf

Could not find a suitable solution, hence this post.
Have 2 sheets - Attendance & Payroll where attendance is filled in a pivoted manner (see sample).
For a given date range, I want to count the number of "Absent" days for the staff. The Non-Array-Formula (in Payroll column "Absent") below does that. Note: column A with staff ids is a dynamic list even though its fixed in the sample.
How this formula works:
match the payroll-staffid to the attendance column-header-staffid
using MATCH
date range given in cells payroll B1,B2
Settings!$B$13 contains the columnar range as per (2)
OFFSET (3) by MATCH to get the staff attendance
COUNTIF the number of "Absent" entries in staff attendance range - CORRECT
ArrayFormula does NOT work when the payroll-staffid "A5" is changed to "A5:A15"
Note: there is no guarantee that payroll-staffids order and attendence-header-staffids are both in same order -> that's why each staffid is mapped MATCHed and OFFSET.
=COUNTIF(OFFSET(INDIRECT(Settings!$B$13),0,MATCH(A5,Attendance!$B$1:$1,FALSE)),"Absent")
Sample sheet here.
=ArrayFormula(VLOOKUP(A5:A15, TRANSPOSE({INDIRECT(AttHeader,FALSE);MMULT(TRANSPOSE(SIGN(ROW(INDIRECT(AttUnitMatrix)))),IF(INDIRECT(AttData,FALSE)="Absent",1,0))}),2,FALSE))
See linked sample sheet in OP.
For defined names; see the Settings sheet. All ranges are computed separately to reduce the size of the formula.
1) Start operating in "block mode", ignoring order of staff-ids. "AttData" is the string representation of the data block and mapped to 1 if "Absent" else 0.
IF(INDIRECT(AttData,FALSE)="Absent",1,0)
2) This matrix is multiplied by a unit row matrix from range string "AttUnitMatrix"
TRANSPOSE(SIGN(ROW(INDIRECT(AttUnitMatrix))))
3) MMULT returns a row of "Absent" counts
4) { } is used to prepend the staff-ids to the "Absent" counts for a 2 row matrix.
{INDIRECT(AttHeader,FALSE);MMULT(...)}
5) TRANSPOSE result to be accessed by VLOOKUP (2 column matrix)
6) VLOOKUP takes care of out of order staff-ids by matching the key-staff-ids to the generated row matrix of (staff-id / absent-count) pairs.
fireworks ... pat on my back :)
In this case and others, and I've sent feedback to Google about this, a feature request "Named Formulas" akin to "Named Ranges", to be used in standard formulas. This is WITHOUT resorting to GAS. When formulas become large, this is NOT a luxury, but a NECESSITY. If readers find such a feature useful, please send feedback to Google.
eg: UnitMatrix($1) => TRANSPOSE(SIGN(ROW(INDIRECT($1))))
MMULT(UnitMatrix(AttUnitMatrix),IF(INDIRECT(AttData,FALSE)="Absent",1,0))

Returns the number of unique values in data studio when date matters

I have my dataset in Google spreadsheet and I wish to know the unique number of customers in a specific date range:
Let's say this is my data set
Customer Date
A 22/07/2017
B 24/07/2017
A 23/07/2017
I use this formula COUNT_DISTINCT(Customer) however because row 3 have different date from row 1 the output is 3 (however, I wish to have 2 as my output)
If you want to know the number of unique values in column A regardless of the date then would this formula work:
=COUNTUNIQUE(A2:A)
Or is you want to combine this with a specific date range then:
=COUNTUNIQUE(FILTER(A2:A,B2:B>=datefrom,B2:B<=dateto))
In this formula, datefrom and dateto can be either a value or a cell reference

Google Sheets - Multipling a cell(weight) by another(rate) based on its value compared to a column of cells

I want to compare the value of cell(K5) against column A to determine the range its rate will fall under. Once the proper rate is determined, I want to multiply that row with its values on column B, C, etc and output it on cells (L5, M5, etc)
for example if the CW(K5) is 755.5 then its range falls under cell A8(500+) so we can multiply CW(K5) by B8 and C8 and output the product on L5, M5 respectively.
Eventually I will have many more rows so is probably a better idea to have rates(columns A, B, C) in a separate sheet, is that even possible?
the actual sheet
I've made similar data sheet, but removed strings with actual numbers to look for in column A. And then used vlookup for sorted range A:C:
The formula for F2 is:
=VLOOKUP(E2,$A:$C,2)
The formula for G2 is:
=VLOOKUP(E2,$A:$C,3)
This technique may help you.

Resources