I have a table of foods with their nutritional values in a Google Sheets. My objective is to enter portions consumed of each food in a given day and calculate nutritional intake for the day. For each row that has a portion entered, I want to summarize the nutritional values times the number of portions served. I've given a very simplified version below.
Can anyone tell me how to go about doing this in Google Sheets?
PORTIONS FOOD CALORIES FAT PROTEIN
1 beef 250 34 25
chicken 220 22 13
carrots 20 12 23
2 beans 40 25 5
--------------------------------------------
TOTALS 330 84 35
In C6 place:
=sumproduct($A2:$A5,C2:C5)
Then copy across to D6 and E6
Related
I'm trying to write a formula in Google Sheets which can first locate the row of a specific value. Then index to the value contained on that row a few columns over.
Let's assume the following
A B C
1 12 80
2 43 35
3 64 15
4 13 56
5 44 93
6 86 48
7 14 31
8 41 3
9 63 56
10 11 46
Values in column B and C have a correlated relationship. I need to first locate a specific value in column B than find it's corresponding value on the same row in column C.
For the sake of example, let's assume I'm trying to locate the row containing the value 41 in column B. And then would like to return the corresponding value in column C, which in this case would be 3.
The reason why I need a formula like this is because the data I'm using is highly variable and large. Over 4000 rows. It is unknown what rows the values to be found sit on.
You may try either:
=filter(C:C,B:B=D2)
OR
=xlookup(D2,B:B,C:C,)
filter() will output all instances of rows(column C) which has 41 in column B while xlookup will pick just the first match of 41 within the column
I have this Google Sheets formula that I encountered in this answers here
answer1, answer2, and I couldn't find the support page for it of Google Sheets.
In layman's terms, please explain how this works.
=A5:INDEX(A2:A,COUNTA(A2:A))
Values
Formula
23
36
42
19
12
26
36
10
19
26
10
I was provided with this refrence to this excel's support page by the #TheMaster.
based on your image...
=A5:INDEX(A2:A,COUNTA(A2:A))
is literally translatable as
=A5:A8
where A5: is start of the range INDEX(A2:A is column of the range end, and COUNTA(A2:A) counts how many cells are not empty in range A2:A
formula
transcript
=A5:
=A5:
INDEX(A2:A,
A
COUNTA(A2:A))
8
note that standalone =COUNTA(A2:A) results in 7 but within the formula its 8 due to INDEX being offset
while it is short it is not reliable in case there are empty cells within A2:A range. therefore it is recommended to use:
=A5:INDEX(A:A, MAX((A:A<>"")*ROW(A:A)))
it's a choice of preference but the above is same as:
=INDIRECT("A5:A"&MAX((A:A<>"")*ROW(A:A)))
I've been struggling for a couple of days now how to get this to work. I have a set of data that I get in a CSV format, that I will copy past in a Google Sheets workbook.
On sheet 1 I have the following (example) data:
Hours Expertise Responsible Rate Total
4 Cleaning Bob 11 44
2 Cleaning Barb 15 30
3 Woodwork Xander 19 57
1,5 Electricity Bob 22 33
There are only 3 responsible people in this example, and I now need to create a sheet per person, showing only their data, but in the same way as it is in the combined sheet.
So what I would like to end up with (for this example) are 3 sheets:
Sheet Bob
Hours Expertise Responsible Rate Total
4 Cleaning Bob 11 44
1,5 Electricity Bob 22 33
Sheet Barb
Hours Expertise Responsible Rate Total
2 Cleaning Barb 15 30
Sheet Xander
Hours Expertise Responsible Rate Total
3 Woodwork Xander 19 57
But to be honest, I'm kinda lost right now. I couldn't get this to work with pivot table or any of the other things I could find with google. I also tried using Vlookup, but then I end up with empty lines in between.
use:
=QUERY({'sheet 1'!A:E}, "where Col3 = 'Bob'", 1)
=QUERY({'sheet 1'!A:E}, "where Col3 = 'Barb'", 1)
=QUERY({'sheet 1'!A:E}, "where Col3 = 'Xander'", 1)
My question is for Google Sheets
I am aware of the countif function and know how to count frequency of one value in a series but I am struggling to find frequency of multiple values in two series. I have tried countifs, arrayformula, countif + sum with and without array formulas but unable to succeed.
example
I have below series in E2:N2
31 32 35 45 49 55 57 66 72 75
and below series in O15:AH15
3 7 12 17 23 25 27 31 39 44 45 48 52 56 61 62 66 69 70 79
I want to see how many values matched and put that in cell A1
In the above example, 3 numbers matched so the value in A1 should be 3
I can do it with countif+countif+countif x 10 times but i wanted a very short formula.
Can someone give me some direction?
Thanks
Try
=SUMPRODUCT(TRANSPOSE(E2:N2)=O15:AH15)
This might serve you: Countifs in Google Sheets with various 'different than' criteria in same row adds +1 value
Basically is how to count based on criteria. there are even 2 sheets for you to check there and copy, you just need to change the criteria of words for the numbers you want to match and count.
I think I’ve ‘over thought’ my problem so I’m starting from the beginning again.
I have two spreadsheets, one is an original database (org_DB) and the second is the updated database (new_DB). The number of rows is around 15,000 for org_DB and 18,000 for new_DB. The number of relevant contiguous columns is exactly 14 in both.
I need a third sheet, the results, that contains only the new_DB entries that are DIFFERENT from the original database, and, all new_DB entries that are ADDITIONAL.
The definition of DIFFERENT is a row with greater than 0 differences.
The definition of ADDITIONAL is a row that has no equivalence.
I think I need the two definitions because ‘new DB’ is longer than ‘org DB’ and all my formulas fail at the end point of org_DB.
The two test sized DB are:
org_DB
Code 1 Code 2 Code 3 Code 4
AA00001 AAGA 1180218 24
AA00007 AAGA 03821787-97 58
AA00008 AAGA 11821260-99 59
AA00009 AAGA 11001017 60
AA00016 AAGA 3801648 67
AA00017 AAGA 3801649 120
AA00018 AAGA 3801692 66
AA00019 AAGA 03821084-61 70
new_DB
Code 1 Code 2 Code 3 Code 4
AA00001 AAGA 1180218 24
AA00008 AAGA 11821260-99 59
AA00009 AAGA 11001015 60
AA00016 AAGA 3801648 67
AA00017 AAGA 3801649 120
AA00018 AAGA 3801692 69
AA00019 AAGA 03821084-61 70
XX00101 XXGA 1234X567X 101
XX00102 XXGB 1234X567X 101
Result DB (the result I am looking for)
AA00009 AAGA 11001015 60
AA00018 AAGA 3801692 69
XX00101 XXGA 1234X567X 101
XX00102 XXGB 1234X567X 101
For row comparison (which works on a row by row basis) I’m using
=if(ArrayFormula(sum(--(new_DB!A2:D2=org_DB!A2:D2)))<>4,"Copy row","Ignore")
To get the result array I’m using
=filter(new_DB,if(ArrayFormula(sum(--(new_DB=org_DB)))<>4)
Problem 1 is that the FILTER condition argument only gets a single formula result from the ArrayFormula so fails with an #N/A - “FILTER has mismatched range sizes. Expected row count: nn, column count: 1. Actual row count: 1, column count: 1.”
Problem 2 is that the ArrayFormula after IF is comparing 1 row and nn columns - which I want. Wrapping the whole function in another ArrayFormula gives even stranger results.
Problem 3. Changing the row comparison function from IF ArrayFormula to SUMPRODUCT produces the wrong result when used in a ArrayFormula wrapper.
I can see that if that if I use this method then the recursion process is likely to be very lengthy - so I've come to accept my method is fundamentally flawed. Should I use a VLOOKUP and FILTER combo for column A. Column A is actually a SKU ID so should always be unique.
Can anyone help please. TIA
Note that org_DB row 3 (AA0007...) is not in the results. Deliberate.
Test sheet here: Test DB Sheet
This will look really ugly really quickly with a lot of columns which is why I'm asking of you have any columns you can limit yourself to.
=ARRAYFORMULA(FILTER(
'New DB'!A2:D10,
ISERROR(MATCH('New DB'!A2:A10 & "|" &
'New DB'!B2:B10 & "|" &
'New DB'!C2:C10 & "|" &
'New DB'!D2:D10,
'Org DB'!$A$2:$A$9 & "|" &
'Org DB'!$B$2:$B$9 & "|" &
'Org DB'!$C$2:$C$9 & "|" &
'Org DB'!$D$2:$D$9,
0))))
This filters the content of New DB by whether the concatenated columns of New DB can be found in Org DB, you can use any other Delimiter if you have | in there.