google spreadsheet change year then table clears automatically - google-sheets

I have question about google spreadsheets.
I have expenses and income table where is all business incomes (from projects) and expenses (salaries/products/licenses).
Is it possible like I have in table year 2020 so it takes from other tables these datas and if I change this year to 2021 it starts over but 2020 is like archived.
Main sheet table:
Expenses
2020
Salaries
$4000
Example I have sheet tab named salaries
date
name
amount
12-02-2020
John Doe
$800
18-04-2020
Mary Doe
$800
20-05-2020
Steven Doe
$800
09-08-2020
Henry Doe
$800
02-11-2020
Jane Doe
$800
12-02-2021
John Doe
$900
18-04-2021
Mary Doe
$900
20-05-2021
Steven Doe
$900
09-08-2021
Henry Doe
$900
02-11-2021
Jane Doe
$900
So if I change in my main sheet table expenses year to 2021 it should automatically find this year salaries from sheet named salaries and sum it up. What would be then $4500.

Solution:
In your main sheet, you can use this formula on cell B2:
=INDEX(QUERY(salaries!A2:C,"select sum(C) where year(A)="&B1&" group by year(A)"),2,0)
The QUERY function pulls the entries on the defined year in cell B1 in main and sum the salaries. The INDEX function removes the header row pulled by the previous function.
Sample Data:
Sample Result:
References:
QUERY()
Query Language
INDEX()

Related

How to match a list to another in google spreadsheet?

Table 1
Name
Surname
Mike Senior
Smith
Sami Albert
Loris
Alfred Tony
Rene
Peter
Flore
Mike Junior
Peterson
Richard Smith
Verna
Table 2
Data
Surname
Barber mike senior
Cell 2
lawyer Alfred tony
Cell 4
chef richard smith
Cell 6
How can I find the correct surnames in Cell 2, Cell 4, Cell 6??
I tried vlookup but it needs an exact match.. it didnĀ“t work.
Assuming you always have to extract the first word of the second table you can do this REGEXEXTRACT:
=REGEXEXTRACT(E2:E," (.+)")
Then, with Proper you can set them to have the first letter as capitals and insert them in VLOOKUP:
=VLOOKUP(PROPER(REGEXEXTRACT(E2:E," (.+)")),A:B,2,0))
And, finally, you can use them as an array if you want:
=ArrayFormula(IFERROR(VLOOKUP(PROPER(REGEXEXTRACT(E2:E," (.+)")),A:B,2,0)))

Conditional formatting base on other column's date that match today in Google Sheets

I have a attendance table. I need to highlight column A who did not fill in record.
Column A is name. How can I use "conditional format" to highlight "Jackson" who did not fill attendance record today when today is 03/08/2022?
My current "conditional format" on Column A is =C2<>""
It is work but I need to change conditional format day by day.
column A
Column B
Column C
Column D
Column E
--------
02/08/2022
03/08/2022
04/08/2022
05/08/2022
John
10:00
10:00
--------------
--------------
May
10:00
10:00
--------------
--------------
Jackson
10:00
--------
--------------
--------------
I don't want to add another reference column between Column A and Column B to index where match today.
Try below formula to CF rule
=INDEX($B$3:$E,MATCH($A3,$A$3:$A,0),MATCH(TODAY(),$B$2:$E$2,0))=""

Comparing 2 columns for certain words

=COUNTIF(B4:B, "" & D4:D & "")
So column B4:B will have something like this
Joe Smith, STIM
and column D4:D would have something like this
Joe Smith 10/19/1999 AC
I am trying to make a True False statment in Col G that if column B has Joe Smith and Column D has Joe smith it will say yes or no. This will be a list of names that always change dynamically so one day B4 might be Joe Smith but the next day it could be Jan Doe. Column D will be a list of names in alpha order that changes all the time as well.
I was able to replicate what you need with the example provided by using:
=ArrayFormula(IF(D:D="",,REGEXMATCH(LOWER(D:D),FILTER(LOWER(I:I),I:I<>"")&"\b")))
You can see the results in my testing spreadsheet here.
At the moment I have limited the range from column I but you can just change it so it takes the whole column.
Just one little detail is that with this function you can only have 1 name in each row in the list of names.

Google Sheets, using Countifs to count number of values in a range, and match another cell's value

Working on a Google Spreadsheet, seems to be behaving differently from excel.
This spreadsheet is integrated from a Google form, responses have a date, and a username.
What I am trying to do is count the number of entries between two dates, and submitted by a certain user.
I.e. the sheet looks like this:
A B C
Timestamp User User Names
2/2/2015 Joe Jones Joe Jones
2/12/2015 Steve Ahn Steve Ahn
2/15/2015 Joe Jones
3/3/2015 Joe Jones
3/4/2015 Steve Ahn
I want to count the number of entries for Joe Jones between 2/14/2015 and 3/4/2015 i.e. return the result of 2 here.
Here is what I have so far:
=COUNTIFS(A1:A15,">="&I1,A1:A15,"<="&I2, B2:B15, C1)
But it throws an error "Array Arguments to COUNTIFS are of different size"
Each bit works as a countifs on its own.
Thanks!
The ranges need to be the same size. Change B2 to B1 and it should work.
=COUNTIFS(A1:A15,">="&I1,A1:A15,"<="&I2, B2:B15, C1)
=COUNTIFS(A1:A15,">="&I1,A1:A15,"<="&I2, B1:B15, C1)

Make an equivalent of a "For" loop

I'm trying to figure out a way to capture information that's essentially a "For" loop in the programming world. I have one sheet that contains unique names and unique quotes:
SHEET 1
Column A Column B
======== ========
John Hello
Mike Hi
Paul Hey
Joe
And then I have another sheet with multiple names, multiple quotes and a number of times quoted (where 0 times does not exist) and the sheet will continue to add new names and quotes every hour:
SHEET 2
Column A Column B Column C
======== ======== ========
John Hi 2
John Hey 1
Mike Hello 8
Sean Hey 4
Paul Hi 1
Jane Hello 2
John Hello 1
... ... ...
OUTPUT EDIT:
Add the number of times that John, Mike and Paul quoted Hello found in Sheet 2, Column C
Add the number of times that John, Mike and Paul quoted Hi found in Sheet 2, Column C
Add the number of times that John, Mike and Paul quoted Hey found in Sheet 2, Column C
SHEET 3
Column A Column B
======== ========
Hello 9
Hi 3
Hey 1
Create a pivot table from Sheet 2 with ColumnB for Rows, ColumnC for Values and ColumnA for Filter. Adjust filter to select only John, Mike and Paul then lookup Hello, Hey and Hi in Sheet1 from the pivot table with say:
=vlookup(B2,'Pivot Table 1'!A$1:B$3,2,0)
in Sheet1 B2 copied down to suit.

Resources