Google sheets tip calculator and tax estimator - google-sheets

I'm having trouble getting google sheets to do what I want it to do.
I have a form that adds new rows into a google sheets spreadsheet
The entries are then further manipulated in new columns that don't correlate to the google form.
I wanted 3 columns of deductions to be subtracted from 1 column being a daily intake
a. example:
[] gForm:Daily bank(A) | gForm:Credit Cards(B) | gForm:Tip outs(C) | gForm:Total Cash(D) | Column E
1 30 30 40 200 100
2
3
I want each line in Column E to automatically populate the code in each new row, that takes column D and subtracts A:C and spits out the difference in Column E.
code example idea: =sum(D:D-sum(A:C))
I made this an Array formula: Below
=ARRAYFORMULA(IF(ROW(G:G)=1, "Total Taxable Cash", IF(ISBLANK(F:F), "", ArrayFormula(F:F-(sum(C2:E2))))))
PROBLEM is that it takes every cell in colums A:C and then subtracts each row in Column D to spit out incorrect answers in Column E.
Does anyone know how to code this so that it adds the code automatically to each new row but also calculate each row individually and not as columns.
Please help me, thank you all.

Michael, your examples in your post are inconsistent. You reference A:D and SUM(C:D), but then your formula example uses G, F and SUM(C2:E). I'll assume that your formula is correct and your example data above it is wrong.
I also don't clearly understand your goal. But at a guess, try this:
=ArrayFormula(IF(ROW(A:A)=1, "Total Taxable Cash", IF(F:F="",,F:F-(C:C+D:D+E:E))))
I've written out some inefficiency and redundancy. But the key change is just swapping your SUM(C2:E2) with (C:C+D:D+E:E).

Related

In Google Sheets, how to check if Cell A (Date) is within the Date range of Cell B and C

I have a sheet with a timeline that shows a month per row in column A and an amount in USD next to that month in column B.
I want to be able to specify amounts in column G with a start and end date for that amount in columns E and F.
What I am trying to achieve is that the values in column B are automatically calculated by looking at the start and end dates specified in columns E and F and then taking the corresponding value from column G if the date in column A falls in between the date range specified in E and F.
I have found many suggestions for similar problems online but wasn't able to get any of them to work for my specific case. Any help is very welcome
You could do it as an array formula like this:
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("`E3:E"&count(E3:E)+2)),"YYMM"))*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))*transpose(indirect("G3:G"&count(G3:G)+2)),(INDIRECT("G3:G"&count(G3:G)+2)+2)^0))
The idea is to develop a 2D array where the rows are the months and the columns are the amounts for matching time periods. Then use the standard Mmult method to get the row totals of the array.
Using indirect for the ranges makes the formula longer but using full-column references would be slow as it would result in a nearly 1000 X 1000 array for a default-sized sheet.
EDIT 1
Or shorter
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("E3:E"&count(E3:E)+2)),"YYMM"))
*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))
,INDIRECT("G3:G"&count(G3:G)+2)))
because you can combine the row totals step with multiplication by column G.
EDIT 2
Alternatively you could just employ a much simpler pull-down formula using SUMIFS:
=ArrayFormula(sumifs(G$3:G,eomonth(E$3:E,-1)+1,"<="&A2,F$3:F,">="&A2))
This uses Eomonth to change all the start dates to the first of the month so they can be compared to the dates in column A correctly. The formula still has to be entered as an array formula because of the Eomonth calculation.
Note
The equivalent pull-down formula to the original array formulas above would be
=ArrayFormula(sumifs(G$3:G,text(E$3:E,"YYMM"),"<="&text(A2,"YYMM"),text(F$3:F,"YYMM"),">="&text(A2,"YYMM")))
but this gives zero for all rows - the reason for this is not obvious to me at time of writing.

Formula to Test for Blanks in two Columns Against a Third Column

So I am using a conditional formatting custom formula to highlight a cell if the column it is summing from another spreadsheet has blanks, but I don't know how to do it with changing ranges. Basically what I want to do is use a third column, say column A, to determine the length of the range (of rows) I want to scan with CountBlank, and if it picks up a blank in there to return a "True".
So basically:
Column A Column B Column C Column D
Person 1 5:30AM 3:00PM 9.5
Person 2 5:00AM 8
Person 3 4:30AM 4:00PM 10.5
So ideally, the cell sums the fourth column with a different function (already have that), and it conditionally formats itself if a blank is picked up in Columns B or C, going all the way down to the last row of column A that has a value. Any help here would be appreciated, thank you.
If I understand you correctly, the custom formula for conditional formatting should be:
=or(countifs(A2:A,"<>",B2:B,""),countifs(A2:A,"<>",C2:C,""))
Suppose you had a list of people's names starting in F2 and their total hours starting in G2. Then you could alter the formula to:
=or(countifs(A$2:A,F2,B$2:B,""),countifs(A$2:A,F2,C$2:C,""))

Google Sheets: Absolute Reference in Formula when Adding Column

I have a spreadsheet that I want to calculate the average of the first three values in a row...
For example:
Column A Column B Column C Column D
Row 1 7/1/2017 6/1/2017 5/1/2017
Row 2 $934 $392 $214
So my formula is
=average($A$2:$C$2)
This works fine, until I add a new column to the left of Column A to add the newest month's data which now looks like this:
Column A Column B Column C Column D
Row 1 7/1/2017 6/1/2017 5/1/2017
Row 2 $934 $392 $214
The issue is that spreadsheet automatically changes the formula to
=average($B$2:$D$2)
when what I really want is to retain the original formula so it will continue to give the the average of the most recent three months of data.
Here is a link to a spreadsheet so you can see what is happening, sheet one is before added column, and sheet two is after adding column.
https://docs.google.com/spreadsheets/d/1XE2zyFGCHUfSf44vNHwXij59I68LJEL_L7cNSf0-uag/edit?usp=sharing
How can I do this? Thanks!
I suggest a sensible place to put such a formula is in ColumnA (having made room for it!) hence:
=average(OFFSET(A2,,1,1,3))

Google Sheets: Script to find duplicates in a column and add their corresponding values from another column

I'm trying to accomplish a lot with little knowledge, but I have a spreedsheet with data that i want to convert into something readable that I can then display on my website.
Anyways, in column A I have a list of dates, column B a list of names, and column c a list of contributions. What I would like to do is first total the amount of contributions in C, for a date range in A.
I would then like to find all the duplicates in Column B(repeat donors), and total their contributions in C.
There is a VBA, that I found on here that would accomplish the second task, but ... I'm using Google Sheets. What I've been doing is sorting the sheet and totalling everything manually.
What I would like to do is first total the amount of contributions in
C, for a date range in A.
Use SUMIF
I would then like to find all the duplicates in Column B(repeat
donors), and total their contributions in C.
Assuming you have 100 records, starting from 1st row for below code.
In cell D1, put =UNIQUE(B1:B10), it will fill D column with unique values of given range (B1:B100).
In cell E1, put =SUMIF(B$1:B$100,D1,C$1:C$100)
Repeat same formula in E column

Google query function

I am trying to return multiple records from a logbook into a final monthly statement... I'm using the query function but I do not get multiple records, it only displays the first match.
My sheets are from 1-31 for days of the month, then the last sheet labeled 717 is for Unit #717's monthly statement.
On Sheet 717, I would like to display information from sheets 1 through 31. Where column A=717, display values from columns B,C,D. Currently, it will only show me the first match. The amount column should show the corresponding rate for that row.
I hope my explanation is not confusing, any help is much appreciated. Thanks.
Here is a link to sample spreadsheet.
As you are concatenating the output of QUERY functions, you are actually performing an "array calculation", and you'll need use an "array calculation enabler", otherwise you will indeed only get the first applicable result.
=ArrayFormula(QUERY('1'!A3:G60;"select B where A=717")&QUERY('1'!A3:G60;"select C where A=717")&QUERY('1'!A3:G60;"select D where A=717"))

Resources