I have a table like this:
☑ 667 No
☐ 667 No
☑ 667 Yes
and want to sum the numbers when the checkbox is checked and the state is YES.
I tried something like this,
=ARRAYFORMULA(SUM(IF(AND(A2:A<>"☐",C1:C="Yes"),B1:B)))
but it is not working.
Anyone can help me?
Please try:
=sumifs(B:B,A:A,"☑",C:C,"YES")
Related
Im trying to get the number between '-' and '-' in google sheets but after trying many things I still havent been able to find the solution.
Data record 1
England Premier League
West Ham vs Crystal Palace
2.090 - 3.47 - 3.770
Expected value = 3.47
Data record 2
England League Two
Carlisle vs Scunthorpe
2.830 - 3.15 - 2.820
Expected value = 3.15
Hopefully someone can help me out
Try either of the following
option 1.
=INDEX(IFERROR(REGEXEXTRACT(AE1:AE4," \d+\.\d+ ")*1))
option 2.
=INDEX(IFERROR(REGEXEXTRACT(AE1:AE4,".* - (\d+\.\d+) ")))
(Do adjust the formula according to your ranges and locale)
use:
=INDEX(IFNA(REGEXEXTRACT(A1:A, "- (\d+(?:.\d+)?) -")*1))
I need to write the regex to fetch the details from the following data
Type Time(s) Ops TPS(ops/s) Net(M/s) Get_miss Min(us) Max(us) Avg(us) Std_dev Geo_dist
Period 5 145443 29088 22.4 37006 352 116302 6600 7692.04 4003.72
Global 10 281537 28153 23.2 41800 281 120023 6797 7564.64 4212.93
The above is the log which i get from a log file
I have tried writing the reg ex to get the details in the table format but could not get.
Below is the reg ex which i tried.
Type[\s+\S+].+\n(?<time>[\d+\S+\s+]+)[\s+\S+].*Period
When it comes to Period keyword the regex fails
If for some reason RichG's suggestion of using multikv doesn't work, the following should:
| rex field=_raw "(?<type>\w+)\s+(?<time>[\d\.]+)\s+(?<ops>[\d\.]+)\s+(?<tps>[\d\.]+)\s+(?<net>[\d\.]+)\s+(?<get_miss>[\d\.]+)\s+(?<min>[\d\.]+)\s+(?<max>[\d\.]+)\s+(?<avg>[\d\.]+)\s+(?<std_dev>[\d\.]+)\s+(?<geo_dist>[\d\.]+)"
Where is your data coming from?
Need to convert Hours & minutes to seconds.
Ex : 5h 30m -> 19800
3h 15m -> 11700
Tried to use Formatting options & the SECOND() function. But it's not working.
if you have 5:30 you can do this:
=TEXT(A7, "[ss]")*1
if you have no idea use:
=INDEX(IFERROR(1/(1/TEXT(REGEXREPLACE(A7:A10&"",
"(\d+)h ?(\d+)m", "$1:$2")*1, "[ss]"))))
Try:
Formula in B1:
=INDEX(IF(A1:A<>"",--REGEXREPLACE(A1:A,"(\d+)h +(\d+)m","$1:$2"),""))
Custom numberformat in B:B is [ss].
Something like this should also work:
=IFERROR(SUMPRODUCT(SPLIT(S4,"hm"),{3600,60}),SPLIT(S4,"h")*3600)
I have a text file of group conversations which I'm trying to analyze. It looks like this:
[4/30/18, 5:49:51 PM] +11 11 111 1111: Thanks for the recommendation.
[4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you!
[4/30/18, 6:00:55 PM] +11 1 11 1111 1111: Nice!
[4/30/18, 6:22:01 PM] +1 (111) 111‑111: sure.. I will look into.
I need to extract every part of each line: date, time, username and the message.
I have been able to separate the Dates and Times using the re package in python by using the code below:
date_regex = re.compile(r'(\d+/\d+/\d+)')
date = date_regex.findall(watsup_content)
time_regex = re.compile(r'(\d{1,2}:\d{2}:\d{2} AM|\d{1,2}:\d{2}:\d{2} PM)')
time = time_regex.findall(watsup_content)
However, I'm having problems getting the users (which sometimes have foreign numbers and sometimes have names) as well as the actual messages which are after the Colon.
I was thinking of using an in-between function for two patterns to get the users... however not sure how to do it... I also don't know how to get the actual messages as well. Your help is greatly appreciated.
Try:
import re
with open('myfile.txt', 'r') as f:
content = f.readlines()
date_regex = re.compile(r'(\d+/\d+/\d+)')
time_regex = re.compile(r'(\d{1,2}:\d{2}:\d{2} AM|\d{1,2}:\d{2}:\d{2} PM)')
for line in content:
print(line)
date = date_regex.findall(line)
time = time_regex.findall(line)
content = ":".join(line.split(':')[3:]).strip()
author = line.split(']')[-1].split(':')[0].strip()
print(date)
print(time)
print(author)
print(content)
print('---')
and you get:
[4/30/18, 5:49:51 PM] +11 11 111 1111: Thanks for the recommendation: bye!
['4/30/18']
['5:49:51 PM']
+11 11 111 1111
Thanks for the recommendation: bye!
---
[4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you! :D:D
['4/30/18']
['5:51:21 PM']
Joe Johnson
It's a pleasure to know you! :D:D
---
[4/30/18, 6:00:55 PM] +11 1 11 1111 1111: Nice! :X
['4/30/18']
['6:00:55 PM']
+11 1 11 1111 1111
Nice! :X
---
[4/30/18, 6:22:01 PM] +1 (111) 111‑111: sure.. I will look into. ::)
['4/30/18']
['6:22:01 PM']
+1 (111) 111‑111
sure.. I will look into. ::)
I am attempting to create a loop to save me having to type out the code many times. Essentially, I have 60 csv files that I need to alter and save. My code looks as follows:
forvalues i = 0203 0206 : 1112 {
cd "C:\Users\User\Desktop\Data\"
import delimited `i'.csv, varnames(1)
gen time=`i'
keep rssd9017 rssd9010 bhck4074 bhck4079 bhck4093 bhck2170 time
save `i'.dta, replace
}
However, I am getting the error "203.csv" does not exist. It seems to be dropping the leading 0, any way to fix this?
You are asking for a numlist, but in this context 0203, with nothing else said, just looks to Stata like a quirky but acceptable way to write 203: hence your problem.
But do you really have a numlist that is 0203 0206 : 1112?
Try it:
numlist "0203 0206 : 1112"
ret li
The list starts 203 206 209 212 215 218 221 224 227 230 233 236 ...
My wild guess is that you have files, one for each quarter over a period, labelled 0203 for March 2002 through to 1112 for December 2011. In fact you do say that you have times, even though my guess implies 40 files, not 60. If so, that means you won't have a file that is labelled 0215, so this is the wrong way to think in any case.
Here is a better approach. First take the cd out of the loop: you need only do that once!
cd "C:\Users\User\Desktop\Data"
Now find the files that are ????.csv. You need only install fs once.
ssc inst fs
fs ????.csv
foreach f in `r(files)' {
import delimited `f', varnames(1)
gen time = substr("`f'", 1, 4)
keep rssd9017 rssd9010 bhck4074 bhck4079 bhck4093 bhck2170 time
save `time'.dta, replace
}
On my guess, you still need to fix the time to something civilised and you would be better off appending the files, but one problem at a time.
Note that insisting on leading zeros, which you think is the problem here, but is probably a red herring, is written up here.