Google Spreadsheet - SUMIF Date Range - google-sheets

I'm trying to create a spreadsheet, in which I want to sum the table if records are older than 1 year.
I have inventory in 1 sheet with purchase date and other stuff, and in 2nd sheet, I want to sum the inventory which is older than 1 year (inspection date is a separate column in 2nd sheet)

sum B column older than year:
=SUMIF(A2:A, ">"&DATE(YEAR(TODAY())-1, MONTH(TODAY()), DAY(TODAY())), B2:B)
sum stuff between two dates:
=SUMIFS(B2:B,
A2:A, ">"&DATE(YEAR(TODAY())-1, MONTH(TODAY()), DAY(TODAY())),
A2:A, "<="&TODAY())

Related

Google sheets Product function with Month comparison

I want to multiply a range by another range in another sheet only If a month in a date from a range matches the month in another range in another sheet.
Technically:
Multiply $R$8:$R$1007 by Start!$L$13:$L$24 If ARRAYFORMULA(TEXT($N$8:$N$1007,"MMMM")),"="&Start!$K$13:$K$24
Edit: here's a sample of my tables:
https://docs.google.com/spreadsheets/d/1A0zZ1BvRnjeQQjsf4RoRGesOPNYOJWzlr9Kh2oYto-Y/edit?usp=sharing
I want the income from US dollars to another currency with conditions.
So in other words column T in sheet Transactions to be equal to the multiplication of the income in US dollars by the exchange rate in column L in sheet Start only If the month from column N equals in sheet Transactions the column K in sheet Start.
How can I right turn this into a functional formula, please?
try:
=ARRAYFORMULA(IFERROR(VLOOKUP(MONTH(N8:N),
{MONTH(Start!K13:K24&1), Start!L13:L24}, 2, )*R8:R))
Based on the limited information of your sheets. The following would multiply and sum each range if the months are matching:
=SUMPRODUCT(--(TEXT(N8:N1007,"mmmm")=Start!K13:K24),R8:R1007,Start!L13:L24)

Google Sheets Date Formula

I have a personal finances Google Sheet with all my expenditures (column A) and corresponding dates (column B) of the month when they are due to be paid.
I would like to create a formula that shows me what is left for the remainder of the month depending on what day of the month I am looking at the sheet.
Something like, ifDate is today, sum all remaining dates of the month expenses.
TIA
Use this formula it works even if the dates is disordered.
=SUMIF(C2:C,">"&F2,B2:B)
Update
=SUMIF(D3:D,">"&TODAY(),C3:C)

Google Sheets SUMIFS comparing one column to another

I am wondering if there is a way to use column comparisons in a SUMIF or SUMIFS function or the DSUM function even. Specifically, I want to compare one value in a row with another value in the same row of data.
For example, let's say I have the following table of data:
Date 1 | Date 2 | Money Earned
1/2/22 | 1/5/22 | $23.00
1/5/22 | 1/3/22 | $11.00
I want to write a formula that sums the values in the 3rd column if Date 1 is last week and if Date 2 is later than or equal to Date 1.
I have completed a workaround solution with 2 hidden columns as follows:
Last week --> =IF(EQ(WEEKNUM(TODAY()) - WEEKNUM(A2), 1), "YES", "NO")
Date 2 After Date 1 --> =IF(B2>=A2, "YES", "NO")
Then I use:
=SUMIFS(C2:C3,D2:D3,"YES",E2:E3,"YES")
It all works, but I am trying to learn to do this a cleaner way without hidden columns that someone might move or delete.
All the examples I can find of SUM or SUMIF rely on the criteria being compared to a singular value that is either hardcoded in the formula or the value of a single cell. I want to compare data from column 1 to column 2 directly for each row. Is this possible with these formulas or any formula in Google Sheets?
In order to check if a date was "last week", you need to consider that the current week might be the first one of the year. So, instead of comparing the WEEKNUM of today with the WEEKNUM of the other date, just compare it to the WEEKNUM of 7 days ago.
Secondly, instead of using "YES" or "NO", you could have used TRUE/FALSE values and remove the need to write IF statements, like this:
last week: =(WEEKNUM(TODAY()-7)=WEEKNUM(A2))
date 2 after date 1: B2>=A2
From there, while it is possible to build an arrayformula for SUMIFS or QUERY, it is easier to just filter the table and sum the results from column C:
=SUM(FILTER(C2:C,WEEKNUM(TODAY()-7)=WEEKNUM(A2:A),B2:B>A2:A))

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, )

How to make a Query formula in Google Sheets for an inventory per month columns

I'm making a dashboard in google sheets for my inventory. i am using query function to populate a section of the dashboard with data as a summary. my source data is set up as item name, type, january, february, march, april, may.... with quantities of the items as values under the months. i want the summary in the dashboard to show only the item, type and total quantity in a month as specified by a field from a list.
https://docs.google.com/spreadsheets/d/1juEwOLFrlwuI7GUtwckZW8AEDPsTXfF9AAdf5vxKBpg/edit?usp=sharing
my current formula
=query(A1:L12,"select B,D,E,F,G,H,I,J,K,L where A='"&$B14&"'",1)
if i search from my dropdown list...
Month: January
Item: AAA
I want to show only the item's 'type' followed by the month I searched for and the corresponding quantities.
right now, my query formula would show me all the month, when i only want to see the one I specified in the "search".
See if this works
=query({A2:B12, filter(D2:L12, D1:L1=B15)}, "Select Col2, Col3 where Col1 = '"&B14&"'")

Resources