Find two identical cells in Google Sheets - google-sheets

I'm trying to set up some kind of check in/out system on Google sheets. So, I'd like to know how long people have been signed in.
Is there a way to AUTOMATICALLY subtract two cells IF and only if these are equal?
For example, subtract time if and only if the names are equal. I'd need to know how long John Doe was signed in for, knowing that other people signed in in-between so I can't assume that names follow each other.
[Timestamp. Name. Sign in or out]
[10:00:00 John Doe sign in]
[11:00:00 John Doe sign out]
Any help would be greatly appreciated, even if you know how to do this in Excel? I've been looking around and wasn't able to find a solution.
Edit: note that I'd like this to be automatic. Whenever somebody inputs their names twice, it recognizes it, gets the name and the time frame.

I think this will do what you want. If a name has a 'Sign in' and 'Sign out' it calculates the logged in time. It handles the same name 'Sign in and 'Sign out' multiple times. And it will be blank if a name only has a 'Sign in'. Be sure to format the column the formula is placed in as time 00:00:00. Copy the formula down.
=if(sumproduct((B2:B=B2)*(C2:C="sign out")*(A2:A))=0,"",if(C2="Sign in",arrayformula(sumproduct((B2:B=B2)*(C2:C="sign out")*(A2:A))-sumproduct((B2:B=B2)*(C2:C="sign in")*(A2:A))),""))

=sumproduct((B1:B2="John Doe")*(C1:C2="sign out")*(A1:A2))-sumproduct((B1:B2="John Doe")*(C1:C2="sign in")*(A1:A2))
that will add up all the sign in and out times, and subtract all the sum of the sign in from the sum of the sign in. For John Doe.
You may want to do a countifs to see if the count of sign ins is equal to the count of sign outs before processing the above. The reason being if you so the math with a sign out, you most likely will wind up with negative time.

Related

exclude certain text from keyword analysis in google sheets

I'm trying to do a little bit of analysis on the topics of emails I receive. I have the emails in a Google-sheet in the format below. I'm trying to count how often 'privacy' or 'confidentiality' are mentioned. My challenge is that pretty much every email signature mentions one of those words, so when i use SEARCH every cell returns TRUE.
Most email signatures start with similar phrases, so I tried deleting anything after those phrases with this formula:
=ArrayFormula(TRIM(LEFT(B1:B,MIN(IFERROR(FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B1:B),LEN(L2))))))
Column B is the column with the email body text in.
However that seems to be deleting text that follows words that aren't in my search (deleting everything after 'not' instead of 'IMPORTANT NOTICE' for instance).
Could anyone advise on either:
what's wrong with my above search
an alternate way of searching for 'privacy' and 'confidentiality' without including text from email signatures.
Example table:
|email title|email body|
|-----------|----------|
|Do you want to buy my stuff| Hi there, I'd like to know if you'd like to buy this thing I want to sell you. IMPORTANT: this email is private|
|two-for-the-price-of-one| I've a great offer for you! This email and attachments are private & confidential|
|Last chance to buy stuff!| Can we have a private call about whether you want to buy my stuff yet?|
In the example above I want to count row 3, but not rows 1 & 2, as the 'private' and 'confidential' mentions in 1 & 2 are in the signature.
Thanks!
I think I understand the error that you've described is occuring with your formula. Once the formula finds one of the values you are using to try to identify an email signature, such as " Important notice", and returns the location of that text, let's say position 96, it then uses 96 for all of the cells, like this: LEFT(B1:B,96). So you might not be able to do the compound arrayformula of an arrayformula that you are trying.
Using the formula like this, in B2, and dragging it down, should work though:
=ArrayFormula(TRIM(LEFT(B2,MIN(IFERROR(
FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B2),
LEN(L2))))))
Note: I'm not sure what value is in your L2.
But for the overall approach, it really depends on how well your terms to identify email signatures work, so as to exclude them from your final full text searches.

Array formula skipping blanks, importing adjacent cell

I am trying to automate simple tasks in my google sheets accounts:
(Link to sheet:here)
I would like all transactions under "Money In" in "Bank Statement" to automatically be entered into "Cash In" with the Descriptions, amounts and payment method carrying over. Similarly, I would like all transactions under "Money Out" in "Bank Statement" to be entered into "Cash Out" with the descriptions, amounts and payment method carrying over. Any help as to how this could be achieved would be greatly appreciated.
I don't understand your approach to the problem given the formula you're using. It seems to me that what you're asking should be a simple FILTER or QUERY, e.g.:
=FILTER(Bank!A4:B, Bank!B4:B<>"")
As player0 states, we don't know much without seeing your sheet and data, however. Theoretically, the above formula placed in Accounts!A4 (or A1, A2, A3) would do what you're describing, given that the range A4:B were previously blank.
UPDATE BASED ON COMMENTS AND SHEET:
Formulas in place:
=FILTER({'Bank Statement'!A3:B,'Bank Statement'!D3:D,'Bank Statement'!C3:C},'Bank Statement'!D3:D<>"",'Bank Statement'!E3:E="")
=FILTER({'Bank Statement'!A3:B,'Bank Statement'!E3:E,'Bank Statement'!C3:C},'Bank Statement'!E3:E<>"",'Bank Statement'!D3:D="")
This could have been done with a QUERY as well. But this may be easiest for you to understand. The setup between the curly brackets is a virtual array, which allows choosing the order of the columns. The two parts outside the curly brackets set the conditions (which are opposite depending on the page).

Count the number of missing required fields in Google Sheets

I have a Google Spreadsheet, used like a form, with multiple "Skills", all of which have 2 fields within them, a "required field" (used as a flag for if entry in that field is necessary) and a "Current field" (where the user provides input). I am trying to create a "Inputs Left" field which counts the number of "Required fields" which do not currently have an entry in the "Current field" across all of the fields (seen below).
To do this, I am currently using this formula (C12:P12 is the range with the values in it).
=COUNT(FILTER(C12:P12,ISODD(COLUMN(C12:P12)-COLUMN(C12)),C12:P12>0)) - COUNT(FILTER(C12:P12,ISEVEN(COLUMN(C12:P12)-COLUMN(C12)),C12:P12>=0))
The issue I am running into is when a "Skill" is not required, but a value is entered. With this formula, it counts this towards the number of inputs left, however I only want it to count towards this if it is a required field, while still allowing the user to input non-required skills (see below). In this situation, I would like to have it still show that 2 inputs a left (specifically skill 3 and 4 still need input)
I believe I could do this using a OnEdit() trigger with google scripts, but I would like to have it done using a formula if possible. I also believe I could do this with a series of normal If statements, but the actual document has many more "skills", and I believe an endless list of if statements would be hard to debug in the future. Any help is appreciated!
Ended up using a COUNTIFS statement:
=COUNTIFS(FILTER(C12:P12,ISODD(COLUMN(C12:P12)-COLUMN(C12))),">0",FILTER(C12:P12,ISEVEN(COLUMN(C12:P12)-COLUMN(C12))),"")
Because I imagine it's confusing why there is a ISEVEN(COLUMN(C12:P12)-COLUMN(C12)) (and ISODD), the reason is because I needed to do multiple of the "Inputs Left" Fields, and the "Required" field would switch between being even and odd, meaning I would need to edit the formula a lot. Using the COLUMN(C12:P12)-COLUMN(C12) normalized this, so the "Current" was always even and the "Required" was always odd.

Google Sheets - Lookup - Multiple lookups, with IF and OFFSET's

I have a small club with my brothers that play golf, where we pay some money depending on how well our rounds go.
When we are done, I enter the scores, fairway hits and putts into a sheet that looks like the one I have attached below.
The Tee Club - Scorecard Sheet
Now, what I am trying to make is a statistics sheets that calculates our average fairway hits, putts etc..
I have that figured out.
But my problem is how to access the data with a formula that I can use for all of us, without having to make too many changes every time. If that makes sense..
Anyway, so far I have this formula:
=IF((OFFSET(HLOOKUP("Mikkel";E3:P28;5;False);0;1;1;1))<=0;"";OFFSET(HLOOKUP("Mikkel";E3:P28;26;False);0;1;1;1))
As it is right there, it searches for "Mikkel" in E3:P28, goes down 5, checks if it's blank or not, if not, it shows the value in F28.
All of this is perfect, except I would like to include a search for "Match 1" and then be able to find the same cell (F28) within that area, but if I change "Match 1", to "Match 2", it should lookup the value of W28 (I know that area is called "Turnering: Februar", but I'll change it). It will contain a total of 18 scorecards listed below and not only those 2 you see on the image.
I'm not quite sure how to explain what I want in any other way, so I really hope that someone can help me..
Let me know if you need more information.
Thanks in advance.
// Mikkel Christensen
Edit: Link for the sheet: https://drive.google.com/open?id=1SFckCG_df4s60JeuS-g-PfKHv9gq2I1b_SI_lP3mDS0

objective c - help creating regular expression for format (#,#)

A user enters his/her number of credit hours per course in my UITextField in this format....
4,3,4,3,3
(4 credit hours for 1st course, 3 credit hours for 2nd course, so on)
Conditions:
The user can only enter in MIN of 1 course and MAX 5 courses, the credit hours must be separated by a comma except for the last one, the string should contain only numbers and commas (no letters etc.) in that order.
I am trying to display an error message if conditions are violated. I think I will need to create a regExp. I am not sure how to create one since the user can enter in 2 courses so... (3,4) and still be okay. (like it cant follow a strict format like phone number).
Rather than letting the user enter what they think is correct and then telling them they're wrong at the end, consider implementing the text field delegate method textField:shouldChangeCharactersInRange:replacementString:. This doesn't preclude you using the regex, but you can also filter the characters typed by the user to prevent any letters and inform the user immediately when they make a mistake.

Resources