SUMIFS With Text and Date Comparison - google-sheets

theoretically I want to sum the total income each employee made for all the businesses.
Like this:
Employee 1 = Biz 1 income + Biz 2 income + Biz 3 income, etc...
Employee 2 = Biz 1 income + Biz 2 income + Biz 3 income, etc...
Technically and based on the table below, I want to sum a range in column R starting from cell R14 where the text in column W starting from W14 is the same in column P starting from cell P14 AND the name of the month in column V starting from cell V14 is equal to a month in date in column N starting from cell N14.
*
(I included the date because this is part of a budget planner so I need to categorize the data based on months.)*
I used this formula:
=SUMIFS(R14:R1013, P14:P1013, U14:U1013, TEXT(N14:N1013,"MMMM"),"="&T14:T1013)
But it prompts me with the error: Array arguments to sumifs are of different size
What could be wrong here? Does someone have any idea?
Thanks for your help in advance!

Try wrapping the text formula into ARRAYFORMULA to get the full column:
=SUMIFS(R14:R1013, P14:P1013, U14:U1013, ARRAYFORMULA(TEXT(N14:N1013,"MMMM")),"="&T14:T1013)

You can get the totals for all months and all employees with query(), like this:
=arrayformula(
query(
{ text(N13:N, "yyyy-MM"), O13:R },
"select Col1, Col3, sum(Col5)
where Col3 is not not null
group by Col1, Col3",
1
)
)

Related

How to Query function for multiple counts

I have a Google sheet being used as a property index which has a list of property with its summary details such as location, type, number of bedrooms etc.
I'm trying to count the number of how many 1 bedroom, 2 bedroom, 3 bedroom properties etc there are in each location.
However, I'm not sure how to do multiple counts, for example where column W = 1 and (next column) where W = 2 etc
=QUERY(Property_Location_Type,"select T, count(T) where W='1' Group by T",1)
you could try something alike:
formula in cell Y1 here:
=ARRAYFORMULA(QUERY({T2:T,TO_TEXT(IF(W2:W>2,">2",W2:W))&{"",""}},"Select Col1, Count(Col2) Where Col1!='' group by Col1 PIVOT Col3 label Col1 'Town/City'"))
-

How to calculate a sum conditionally based on the values of two other columns

Feels like this may be a basic, but I cannot find a way to do this with sumifs.
I've got four columns in one table, representing the workload of an employee like this:
Job
Employee # 1
Employee # 2
Workload
Job 1
Bob
Jane
5
Job 2
Bob
2
Job 3
Jane
Susan
3
Job 4
Susan
2
I'd like to output total workflow results to a second sheet for each employee based on a specialized formula. In English, the forumla would be:
Calculate the total workload for each employee.
- For each job that includes that includes employee named "X" and no assigned teammate, use the job's corresponding workload value.
- For each job that includes that includes employee named "X" and has an assigned teammate, reduce the corresponding workload value by 50%.
So with the given table above, I'd want an output like this:
Employee Name
Workload
Bob
4.5
Jane
4
Susan
3.5
Math:
Bob = ((job_1 / 2) + job_2)
Jane = ((job_1 / 2) + (job_3 / 2))
Susan = ((job_3 / 2) + job_4)
Does anyone know how I can accomplish this?
Functions like sumifs seem to only let me set criteria to sum or not sum a value. But I cannot find a clear way to sum only 50% of a value based on a condition in a separate column.
=LAMBDA(name,SUMIFS(D2:D5,B2:B5,name,C2:C5,"")+SUMIFS(D2:D5,B2:B5,name,C2:C5,"<>")/2+SUMIFS(D2:D5,C2:C5,name)/2)("Bob")
The math is
SUM D, if B is Bob and C is empty and
SUM half of D if B is Bob and C is not empty and
SUM half of D, if C is Bob.
Or the same logic via query:
=QUERY(
{
QUERY(B1:D5,"Select B,sum(D) where C is null group by B");
QUERY(B1:D5,"Select C,sum(D)/2 where C is not null group by C");
QUERY(B1:D5,"Select B,sum(D)/2 where C is not null group by B")
},
"Select Col1, sum(Col2) where not Col1 contains 'Employee' group by Col1"
)
However, note that we're assuming title contains Employee and no other names contain Employee.
Employee # 1
sum sum Workload
Bob
4.5
Jane
4(Incorrect in the question)
Susan
3.5
Use this formula
=ArrayFormula({ "Employee Name", "Workload";
QUERY(
QUERY({LAMBDA(a,b,c,d,k, {b,a,{d/k};c,a,{d/k}} )
(A2:A,B2:B,C2:C,D2:D,
BYROW(B2:C, LAMBDA(c, IF(COUNTA(c)=0,,IF(COUNTA(c)=1,1,2)))))},
"Select (Col1),sum(Col3) Group by Col1" ,0), "Where Col1 <> '' ",0)})
Used formulas help
ARRAYFORMULA - QUERY - LAMBDA - BYROW - IF - COUNTA - SUM

Google Sheets - Sum row values in vlookup

I have G-Sheet like this one here:
Sales Weekly
In Sheet2 column I, I want to get sum qty from value in sheet Price
I have a formula like this:
TOTAL AVERAGE = Total Qty (week) * Grand Total
Then the expected sum qty from Price sheet is calculated with Grand Total
First, I've tried:
=SUM(VLOOKUP(A3, Price!C2:F, 4, False))*H3
Second, I've tried:
=ARRAYFORMULA(VLOOKUP(A3, Price!F3:H, 3, False))*H3
All formulas don't get a value that I expect.
How can I achieve that?
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A3:A; QUERY({Price!D2:F};
"select Col1,sum(Col3) where Col3 is not null group by Col1"); 2; 0)*H3:H))

How do I create a formula to sum values in one column, but multiply those values by a different column?

I have two Google Sheets. My main sheet keeps track of meetings (total, or "count"), minutes, and meeting categories:
Count Mins Category
1 30 Hiring
5 60 Lunch
3 120 Tasks
1 60 Hiring
2 30 Tasks
...
And here's the sheet I'm trying to figure out:
Categories Count Mins
Hiring 2
Lunch 5
Tasks 5
The "Count" column is correct (I'm using a sumif formula), but I'm not sure how to get the "Mins" column and multiply it by the "Count" column. (To get the total meeting time for the Tasks category I need to add (120 * 3) and (30 * 2).
Is there a way to do that?
use:
=QUERY(QUERY(A1:C,
"select C,sum(A),sum(B)
where A is not null
group by C"),
"offset 1", 0)
then:
=QUERY(QUERY(QUERY(QUERY(A1:C,
"select C,sum(A),sum(B)
where C is not null
group by C"),
"offset 1", 0),
"select Col1,Col2*Col3"),
"offset 1", 0)
After a bit more research I stumbled upon SUMPRODUCT and that turned out to be an easy solution. I'm not familiar with "Query" but it looks super powerful. (Is it similar to SQL?)
Anyway, here is my solution:
=SUMPRODUCT((N6:N1500 = A2),(E6:E1500), (J6:J1500))
If the Category in the N column is a match, multiply the value in the E column by the value in the J column. Easy peasy.

How to SUM rows filtered by multiple criteria

Google Sheets question.
I have the following sheet (named "x") containing expenses:
Date Sum Category
1/Jan/2017 100 red
2/Jan/2017 200 blue
3/Jan/2017 10 red
4/Jan/2017 20 blue
1/Feb/17 1 red
2/Feb/17 2 blue
I need to compute monthly totals, per category:
Month Red Blue
Jan/17 110 220
Feb/17 1 2
My current solution is to place in each result cell something like:
=SUM(IFERROR(FILTER(x!$B:$B, MONTH(x!$A:$A)=MONTH($A2), x!$C:$C="red")))
I am asking if there is a better way. I want to have a single result formula working over an array (maybe an ArrayFormula?!) instead of placing and customizing my formula in each cell.
Any ideas?! Thanks!
Well this is the basic idea of using pivot tables but not quite there because I can only get the month as a number so far
query(A:C,"select month(A)+1,sum(B) where C<>'' group by month(A) pivot C label month(A)+1 'Month Number'")
EDIT
The month number can be changed to a month name using an array formula and VLOOKUP but the formula is getting a bit long (my table of month numbers and names is in columns I & J)
=arrayformula({vlookup(query(query(A:C,"select month(A)+1,sum(B) where C<>'' group by month(A) pivot C label month(A)+1 'Month Number'"),"select Col1"),I:J,2,false)})
and you've still got to pick up the other two columns - this is the whole thing
=arrayformula({vlookup(query(query(A:C,"select month(A)+1,sum(B) where C<>'' group by month(A) pivot C label month(A)+1 'Month Number'"),"select Col1"),I:J,2,false),query(query(A:C,"select month(A)+1,sum(B) where C<>'' group by month(A) pivot C label month(A)+1 'Month Number'"),"select Col2,Col3")})

Resources