A company has a list of clients, i, all of which delay their payments by X_i. The problem is to create a spreadsheet that will show the sum of positive cashflows for a given day, where the delay of incoming cashflows can be manually adjusted.
The input is:
Date
Amount Due $
Client
Expected Delay (Days)
01
100
A
2
02
5
B
0
02
30
C
1
03
50
B
0
The output needs to be:
Date
Total Inflows $
01
0
02
5
03
180
How can I code this in Google Sheets?
Use for date:
=UNIQUE(A2:A)
and for totals:
=ArrayFormula(IF(LEN(F2:F),SUMIF(A2:A+D2:D,F2:F,B2:B),))
if in date column you have text values you need convert it to real dates and format as you want
Related
I have this row in Google Sheets with the year and Week yyyy-ww which starts at week "0".
A B C D E
1 2022-00 2022-01 2022-02 ... 2023-00
How do I convert to a "Date Range" like this in Google Sheets?
A B C D E
1 Dec 26 - Jan 1 2 Jan - 8 Jan 9 Jan - 15 Jan ... ...
I'm not sure if this is what you are looking for but this is a math formula that gets you your results. Paste it in A2 and it will spill over through all the columns.
=ARRAYFORMULA(IF(A1:1<>"",TEXT(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)-6),"mmm dd")&" - "&TEXT(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)),"mmm dd"),""))
You could then copy and paste the values over your original row. Assuming you want to convert your current format over to this new format permanently.
If you are looking for a way to literally format the cell, I do not believe that is possible from a yyyy-ww format.
UPDATE:
If curious, a shorter version using LAMBDA would look like:
=ARRAYFORMULA(LAMBDA(a,IF(a>0,TEXT(a,"mmm dd")&" - "&TEXT(a+6,"mmm dd"),""))(DATE(LEFT(A1:1,4),1,1)+(7*RIGHT(A1:1,2)-6)))
can you try this out:
=BYCOL(A1:G1,LAMBDA(ax,LAMBDA(s,w,LAMBDA(z,iz,IFS(iz=1,text(MAX(z)-6,"MMM D")&" - "&text(MAX(z),"MMM D"),iz=53,text(MIN(z),"MMM D")&" - "&text(MIN(z)+6,"MMM D"),(iz<>1)+(iz<>53),text(MIN(z),"D MMM")&" - "&text(MAX(z),"D MMM")))(FILTER(s,w=--RIGHT(ax,2)+1,YEAR(s)=--LEFT(ax,4)),FILTER({w},w=--RIGHT(ax,2)+1,YEAR(s)=--LEFT(ax,4))))(SEQUENCE(DAYS("12/31/2025", "1/1/2020")+1,1,DATE(2020,1,1)),INDEX(WEEKNUM(SEQUENCE(DAYS("12/31/2025", "1/1/2020")+1,1,DATE(2020,1,1)))))))
Keeping track of finances!
Situation: every month I have a Direct Debit that moves an amount (e.g. £25.00) from one bank account to another to pay a bill.
Sheets: Every month on a specific date I want to automatically increase a specific cell that starts at £0.00 with the amount £25.00 that is in another cell.
Example:
A1 - Netflix
B1 - £25.00
C1 - Netflix Payments
D1 - £25.00 on Jan 1st, £50.00 on Feb 1st, £75.00 on Mar 1st etc
In D1:
=B1*(DATEDIF(DATEVALUE("Jan 1, 2022"),TODAY(),"m")+1)
This will continue to multiply the value in B1 by the number of full months since the start date of January 1, 2022. That is, if the B1 value is 25, then today, the D1 value will be 25; on February 1, 2022, it will automatically read 50, on March 1 it will read 75, ad infinitum.
Use now() formatted to month (as a number) and multiply the 25 by that result.
Jan is 1, Feb is 2, March is 3 etc
So 1 * 25 = 25, 2 * 25 = 50...
I have a workbook where I track game stats for my local community. I added a chart that changes upon a few selections and I use filter to get the desired result. The data comes from a sheet where I use query to calculate month to month differences (since I could not find this easily done with google's provided pivot options). One of the query's looks like this
=query('Response Edits'!1:1112,"select A,B,C WHERE A IS NOT NULL AND NOT H matches '"&textjoin("|",TRUE,query('Response Edits'!1:1112,"select min(H) WHERE A IS NOT NULL group by D",0))&"' order by D, C ASC",0)
A converts the month value in the timestamp to the correct survey month (e.g. a 2020-07-01 would be for 06 survey and 2020-07-29 would
be for 07 survey)
B converts the year value in the timestamp to the correct survey year
C is the timestamp of the survey submission
D is the player name
H is the player XP of the survey submission (I use this as a lazy solution since it only increases and because I could not figure out a
way to include the key phrase date using multiple datetime e.g.
NOT C matches date texjoin("|",TRUE,"select min(C)...") did not work)
the textjoin is just to remove the earliest date submitted because it would not have a month to month value. Here is a portion of the output of the query above and another query which I believe is correct:
7 2020 2020-07-31 23:18:48 ... 6873449 198 11610
8 2020 2020-08-31 22:15:53 ... 7789713 175 8732
9 2020 2020-09-30 23:03:12 ... 5994347 139 8932
When I close the the sheet and reopen it I notice that my chart has only 0 values because my sheet with the query functions is only outputting 0. The above query and my other query have also given a different output, which I have provided a portion for below:
6 2020 2020-06-30 22:04:02 ... 0 0 0
7 2020 2020-07-31 23:18:48 ... 0 0 0
8 2020 2020-08-31 22:15:53 ... 0 0 0
9 2020 2020-09-30 23:03:12 ... 0 0 0
I am new to using query, but the formula seems correct, because if I change the last 0 in the formula (which is the option for header) to 1 and then back to 0 I get the desired result.
Tl;dr Why does the queried data not output correctly when I close and reopen a workbook? And why does it output correctly after the formula is changed and changed back (including selecting undo)? Is it potentially textjoin or matches causing the problem in the query?
try to run this:
=QUERY('Response Edits'!A1:H1112,
"select A,B,C
where A is not null
and not H matches '"&TEXTJOIN("|", 1,
QUERY('Response Edits'!A1:H1112,
"select min(H)
where A is not null group by D", 0))&"'
order by D, C", 0)
I have a 200+ rows of timestamps. I have two cells, say 4am and 10am. I'm trying to write an If statement to see which rows time is between 4am and 10am, regardless of the day, month or year.
For example, B1 = 4am and B2 = 10am
A4 = "1/1/2020 3 am"
A5 = "1/2/2020 5 am"
A6 = "3/3/2020 11 am"
etc...
So only A5 would meet the conditions
Here's my pseudo-code:
IF(AND(A4>$B$1,A4<$B$2),"in between","NOT")
but column A has a timestamp format and I need to strip off the date part and just compare the times. I'm trying to do this in google sheets.
You're going to want to compare the data after running it through TIMEVALUE.
So instead of just referencing cell A4, you'd reference TIMEVALUE(A4), for example.
This will trim the date data from the string and you'll end up getting a number between 0 and 1. For example, TIMEVALUE("12:00 PM") would return 0.5.
I'm trying to sum values across multiple Google Sheet spreadsheets (workbooks) that are grouped by dates. For example, I want to sum all the Delta values for March 2, 2020 across multiple spreadsheets and each spreadsheet will have 0 or more values for that date.
Here's an example with 2 spreadsheets:
Spreadsheet 1:
Date Start Stop Delta
Mon 02Mar20 16:51 16:56 0:05
Mon 02Mar20 16:56 17:00 0:03
Tue 03Mar20 18:45 18:49 0:03
Tue 03Mar20 19:04 19:06 0:01
Spreadsheet 2:
Date Start Stop Delta
Mon 02Mar20 8:38 8:49 0:11
Tue 03Mar20 4:47 4:50 0:03
Tue 03Mar20 17:42 17:55 0:13
Tue 03Mar20 17:58 18:45 0:47
Tue 03Mar20 18:53 19:03 0:10
I want to have a dynamic sum of the Delta columns across spreadsheets by each day in a separate spreadsheet. So here's what I would like to autogenerate. Specifically, the sum of the Delta values for Spreadsheet 1 and Spreadsheet 2 for each day (0:08, 0:11, 0:04, 1:10):
Date Total Spreadsheet 1 Spreadsheet 2
Mon 02Mar20 0:19 0:08 0:11
Tue 03Mar20 1:14 0:04 1:10
I tried using IMPORTRANGE but I'm not sure how to make the sums dynamic for each day. I don't know ahead of time how many entries I'll have for each date in Spreadsheet 1 and 2 so I want to have a way to auto determine how many rows to sum up each day for Spreadsheet 1 and 2. I'm guessing I would need to use QUERY or FILTER to filter all the imported values from IMPORTRANGE but I'm not sure how to do that.
I made an easy dataset to be sum up. Got a Spreadsheet like this:
As you can see, the total sum values for 2nd march would be 2 and for 3rd March would be 20.
In a different Spreadsheet, got my dashboard:
The formula I've used in B2 is:
=SUMPRODUCT(--(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!A1:A4")=$A2);IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!B1:B4"))
This is how it works:
--(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!A1:A4")=$A2) will compare the values of column A in Workbook 1 with the date in column A in my main dashboard. Because we've used a double unary operator this will return an array of 1 and 0 if there is a match or not (in this case, it will be an array like {1;1;0;0}
IMPORTRANGE("https://docs.google.com/spreadsheets/d/1rnap9LJQJaqriiJLSsF7EWQLwBUiNviktxDAMFfW0ZE";"Hoja 1!B1:B4") will return as array the values of column B in Workbook 1, in this case it will return {1;1;10;10}
SUMPRODUCT will multiply both arrays and sum up the values, in this case {1;1;0;0} * {1;1;10;10} = {1;1;0;0} and the sum up of this final array is 2.
Same logic applied to second date, we would obtain {0;0;1;1} * {1;1;10;10} = {0;0;10;10} -> 20
Just add each workbook in 1 different column with same formula, and then do a normal sum up in your main dashboard to get the Grand total sum for all values in all workbooks for a specific date:
Hope this helps.
NOTICE: Of course, this method will work only if your dates are dates (not strings/texts) and the times in Delta are date/times too (not strings/texts)