Finding the total number of hours logged in - if-statement

There is this google form where people would enter the time they login and then enter the time they logout from - let's say volunteering. The point of the google sheet is to calculate the total number of hours a certain person volunteered for the entire time.
Ex. If I chose to see how many hours "John" volunteered for, it should show the total hours he has done based on the data he entered
I have also included the linked to a copy of the google sheets if my explanation doesn't really make sense. LINK
In the next sheet, I have created a timesheet for 5 days of the week that the user choose. In other words, it calculates the total hours for 5 days that the table shows.
I researched how to separate the data where if the name is "John", then only look at the data given for John and no one else...then calculating the total hours, but none gave a specific answer for an if statement looking at a column for a certain word.
I want to somehow make the sheet to ignore the dates and, for example, if I choose "John", it will only calculate the hours for each time he clocks in and displays the total amount of hours he volunteered. Any tips would be helpful!

I guess the problem here is to count between times when it crosses midnight.
In Excel the following should work:
=SUMPRODUCT(--(B2:B9="John"),MOD(F2:F9-E2:E9,1))
I guess in Google Sheets the following:
=SUMPRODUCT(--(B2:B="John"),MOD(F2:F-E2:E,1))
Format the outcome into the format you like. If you want total hours then [H] should do.
Note that this doesn't work when one would work over 24 hours. In that case you need datetime values to work with.

Format >> Number >> Length "column f"

delete everything in range D8:F
paste in D8:
=ARRAYFORMULA({
IFERROR(FILTER({TEXT({'Form Responses 1'!E$2:E, 'Form Responses 1'!F$2:F}, "h:mm:ss am/pm"),
TEXT('Form Responses 1'!F$2:F-'Form Responses 1'!E$2:E, "[h]:mm")},
'Form Responses 1'!B$2:B=C$3, 'Form Responses 1'!D$2:D=B8), {"","",""});
IFERROR(FILTER({TEXT({'Form Responses 1'!E$2:E, 'Form Responses 1'!F$2:F}, "h:mm:ss am/pm"),
TEXT('Form Responses 1'!F$2:F-'Form Responses 1'!E$2:E, "[h]:mm")},
'Form Responses 1'!B$2:B=C$3, 'Form Responses 1'!D$2:D=B9), {"","",""});
IFERROR(FILTER({TEXT({'Form Responses 1'!E$2:E, 'Form Responses 1'!F$2:F}, "h:mm:ss am/pm"),
TEXT('Form Responses 1'!F$2:F-'Form Responses 1'!E$2:E, "[h]:mm")},
'Form Responses 1'!B$2:B=C$3, 'Form Responses 1'!D$2:D=B10), {"","",""});
IFERROR(FILTER({TEXT({'Form Responses 1'!E$2:E, 'Form Responses 1'!F$2:F}, "h:mm:ss am/pm"),
TEXT('Form Responses 1'!F$2:F-'Form Responses 1'!E$2:E, "[h]:mm")},
'Form Responses 1'!B$2:B=C$3, 'Form Responses 1'!D$2:D=B11), {"","",""});
IFERROR(FILTER({TEXT({'Form Responses 1'!E$2:E, 'Form Responses 1'!F$2:F}, "h:mm:ss am/pm"),
TEXT('Form Responses 1'!F$2:F-'Form Responses 1'!E$2:E, "[h]:mm")},
'Form Responses 1'!B$2:B=C$3, 'Form Responses 1'!D$2:D=B12), {"","",""})})
paste in: F13:
=ARRAYFORMULA(TEXT(SUM(IFERROR(TIMEVALUE(F8:F12))), "[h]:mm"))

Related

Duplicate data occurs when order_by ('?') and pagination is applied

#action(detail=False, methods=["get"])
def home_list(self, request):
data = extra_models.objects.order_by("?")
print(data)
paginator = self.paginator
results = paginator.paginate_queryset(data, request)
serializer = self.get_serializer(results, many=True)
return self.get_paginated_response(serializer.data)
What I want to do is, I want the data of extra_models (objects) to come out randomly without duplication every time the home_list API is called.
However, I want to come out randomly but cut it out in 10 units. (settings.py pagination option applied)
The current problem is that the first 10 appear randomly, but when the next 10 appear, the first ones are also mixed.
In other words, data is being duplicated.
Duplicates do not occur within the same page.
If you move to the next page, data from the previous page is mixed.
Even if you try print(data) or print(serializer.data) in the middle, duplicate data is not delivered.
However, data duplication occurs from /home_list?page=2 when calling the actual API.
Which part should I check?
You should expect this behaviour when you're dealing with .order_by("?").
Whenever a request hits in server's end, Django shuffles the objects and also Django doesn't preserve the previous request or page
You are doing nothing wrong here, The only reason why this is happening is because of order_by("?"). The API is stateless which means on the second API call when you call for Page=2 then it does not know which data is sent for page=1 and returns random data for page=2.
The only solution is to order your data by ASC or DESC

Facebook API Page : get total likes, total comments and total posts likes

I want to get the total likes of a page, total comments & total likes from posts (summarized).
I'm able to get the total likes of a page with the query:
{page_id}/?fields=fan_count
But I don't know how to get the total likes & comments from all posts summarized.
I'm looking for something like:
Page ID 10202
1029 Page likes
293 Page Posts comments
2933 Page Posts likes
I know that if I execute the query:
{page_id}/posts?fields=message,likes.limit(1).summary(true)
It will return me all the posts in that page with the total likes, but I don't want to loop through all the posts to know how much likes/comments I have.

Formula Won't Stop Skipping Lines When Writing Data

I'm currently working on a project using Google form to gather data into an excel sheet, and then organize the data based on answers of the form. After an employee selects a department and submits a form, I would like to filter each response by department to its own page within the workbook.
I've listed my current formula below. As of now, it will only import the data on the same row when it is sorted into a new page, thus leaving many blank spaces in between information. Is there a way to make sure it will not skip rows during the import?
=IF(REGEXMATCH('Form Responses 1'!D2:D1101, "Department Name"), 'Form Responses 1'!B2:B1101," ")
try:
=FILTER('Form Responses 1'!B2:B1101,
REGEXMATCH('Form Responses 1'!D2:D1101, "Department Name"))

Facebook FQL Query only returning a limited amount of objects?

I am running an FQL query through the Facebook api:
SELECT username FROM page WHERE CONTAINS("Musician/Band")
I am expecting this to return a large amount of items, but it only returned about 100. Is there a limit on the amount of items a query like this will return? Or is this just not a query that is written wrong? In case you couldn't tell, I wanted the usernames of all of the musical artists on FB.
Thank you for your insight.
FQL has LIMIT and OFFSET keywords. You can get upto 5000 results at a time but better way to do it is through pagination
eg:
SELECT username FROM page WHERE CONTAINS("Musician/Band") LIMIT 200 //gets first 200 results
SELECT username FROM page WHERE CONTAINS("Musician/Band") LIMIT 200 OFFSET 201 //to get next 200 results
and so on..
Also you can use Facebook multiquery to minimize number of queries made.

Issue getting insights from FQL api

I am interested in returning back a few metrics from insights but i am having difficulty getting results from FQL.
I need to get back the following.
page impressions/likes/shares
posts impressions/likes/share/comments
For post impressions
fql?q=SELECT metric, value FROM insights WHERE object_id=#### AND metric='post_impressions_unique' AND end_time=end_time_date('2011-10-30') AND period=period('lifetime')
For page impressions
fql?q=SELECT metric, value FROM insights WHERE object_id=#### AND metric='page_impressions' AND end_time=end_time_date('2011-10-30') AND period=period('lifetime')
i get back empty data sets:
{
"data": [
]
}
What am i doing wrong?
I had the same problem at first. According to the documentation, 'page_impressions' and 'page_impressions_unique' can only take the periods of 'day', 'week', and 'days_28'. If that doesn't fix the problem, try changing to a different end date (which was my problem).