Daily totals, by tag - emacs

I've recently started using org-mode (and Emacs in general) and I love the time tracking elements. It is probably the first solution that accurately represents what had previously worked for me in my paper based system.
I'm not overly familiar with the reporting capabilities so this question is more one for guidance:
Is it possible to produce a report for a given week, that totals up the time spent on tags for each day?
For instance:
Monday
2 hrs :support:
3 hrs :support:
1 hr :meetings:
And from there produce me a table that would have the totals for Monday, Tuesday, etc:
Monday
Total :support: 5 hrs
Total :meetings: 1hr
The format is not relevant, more so just the ability to automate what I currently have to do manually - add up the tags, per day and log in a time-sheeting application.
Please keep in mind I'm still learning so if I come up with a solution myself, I'll include it here.
Cheers!

If you've not got there yourself yet, what you're looking for is clock tables in org-mode. See here for details.
There are a great many ways of filtering and breaking down the information presented. As an example, I use the following clock table to get a report of what I did last week broken down by day; I then use this when filling in my timesheet.
#+BEGIN: clocktable :maxlevel 3 :scope agenda-with-archives :block lastweek :step day :fileskip0 :formatter :link 2 :indent t :narrow 79 :formula % :tags "-NOCLOCK"
#+END:
This is reasonably self-explanatory if you read that link to the org-mode manual. The -NOCLOCK tag filter allows me to mark some tasks such that they never appear in the report. I use this for 'lunch', for example.
Once you're written this clock table specification just put the point in it and press C-c C-c.
This then gives you a clock table looking like the following (only Monday is shown in this example, and with a very limited set of test data for that report, but you get the idea):
Daily report: [2014-11-24 Mon]
File Headline Time %
---------------------------------------------------------------------------------------------------------
ALL *Total time* *0:25* 100.0
---------------------------------------------------------------------------------------------------------
agenda.org *File time* *0:14* 56.0
[Org-mode maintenance] 0:14 56.0
[STARTED {#B} Weekly review] 0:14 56.0
---------------------------------------------------------------------------------------------------------
work.org *File time* *0:11* 44.0
[Default task to soak up time when not clocked into a specific task] 0:11 44.0
[STARTED Non-specific work activity] 0:11 44.0
The time is nicely broken down as per the task breakdown, summarised at each level.
You asked about doing this for tags; you could use the tags filter parameter on the clock table definition to achieve that, either summarising them into the same table, or having separate tables for each tag.

Related

Why is Date.getMinutes() returning 2 for the time 4:00 PM?

I'm creating a customized function that does some calculations for a given time.
When a time is entered in a cell, for example 4:00 PM, this is automatically converted into a date, in this case 12/30/1899 16:00:00 and when the function getTheMinutes() is called, it returns 2 instead of 0.
function getTheMinutes(dateTime){
return dateTime.getMinutes();
}
The behavior of the function is different if it's used for a most recent date like 5/1/2019 16:00:00.
I want the user to be able to just write a time in a cell then use the customized function in another cell. Please let me know your thoughts.
Now that you have indicated the time zone for your spreadsheet I can confirm what #RobG deduced almost a day ago, which is that Guatemala adjusted its difference relative to UTC. Something you have confirmed is treated as by two minutes with effect from October 5, 1918.
More specifically, the adjustment was of 2 minutes and 4 seconds and effective from 03:00 that day:
(Source IANA Version 2019b file northamerica.)
There have been very many such minor adjustments around the world over the years (even between towns in the same country) and adjustments continue, though usually of a whole hour – between 'standard' and Summer time. Sheets has very properly recognised that "normal arithmetic" 'does not work' across such a transition and while noon yesterday to noon today for example is normally, for any one specific location, a difference of 24 hours it is often 23 hours or 25 hours on the day that clocks go forward/back.
And the moral of the story is to beware of obliging Sheets to assume, for want of a specific date, that is has the index number 0 - i.e. is December 30, 1899.
I made some testing, and I found out that the formula is giving a wrong result any minute before 10/5/1918 0:03:00, from that DateTime on, the formula is working as expected.
Here is my sheet https://docs.google.com/spreadsheets/d/1psm8_GJYRczO53TILJCOzo0p4GpnS-ooiGWqOJrC8ZU/edit?usp=sharing
I would need to do a date validation in my customized formula to make it useful. I don't know why google sheets is choosing that date as default when just a time is typed in a cell, I think it should be improved.

Tableau - Finding Records that happened within X amount of time

I have some experience with Tableau as I have migrated into a Data Analyst position with not a ton of experience and am hitting a wall with if it is even possible to perform the calculation within Tableau.
The general base of my data would look like (Limiting it to the two fields we need)
Case # | Tech Dispatch Time (PST) | Full Time (Y/N)
2017-0001| MM/DD/YYYY 16:34:21 | 0
2017-0002| MM/DD/YYYY 20:43:00 | 1
2017-0003| MM/DD/YYYY 22:00:05 | 0
We are looking to see how often a dispatch happens within X amount of time to determine our efficiency in dispatching our teams. If these were happening on the same record, a basic DATEDIFF and IF function would work, but I am at a loss on how to state that IF there is another dispatch in say 180 minutes, 1, else 0.
Is this something I will have to do outside of Tableau within say SQL or PowerPivot? Or is this a function that Tableau could calculate as well?
Thank you for your time and assistance with this matter,
Andy M.
Create a parameter to define your 'x',
Then create a calculated field with below Formula(I called it time block)
//We need to add 0.5 to Roundup
ROUND((DATEDIFF('minute',[Tech Dispatch Time],NOW())/[x])+0.5,0)
Now you can use it in your viz
Use the LOOKUP() function. It allows you to find other rows' values relative to the current row.
DateDiff("minute", [Tech Dispatch Time (PST)], Lookup(MIN([Tech Dispatch Time (PST)]), -1))
The sample data you have in your question presents a problem though. The Tech Dispatch Time (PST) field only has the time portion. To accurately calculate time difference, you need a date with the time. Otherwise, you will end up with negative times if the two cases span across midnight.
Since this is a table calc, you'll also have to set the partitioning and addressing dimensions and sort order by editing the table calc to get the effect you want.

Joining time series events with daily 'shift' data?

What is the best practice for joining 'shift' data and other time series data in Tableau? I am working with multiple geo data (from LA to India, UK, NY, Malaysia, Australia, China etc), and a lot of employees work past midnight.
For example, an employee has shift at 9 PM to 6 AM on 2016-07-31. The 'report date' is 2016-07-31 but no time zone information is provided.
This employee does work and there are events (time stamps in UTC) between 2016-07-31 21:00 to 2016-08-01 06:00. When I look at the events though, 7/31 will only have the events between 21:00 and 23:59. If I filter for just July, my calculations will be skewed (the event data will be cut off at midnight even though the shift extended to 6 AM).
I need to make calculations based upon the total time an employee was actually engaged with work (productive) and the total time they were paid. The request is for this to be daily/weekly/monthly.
If anyone can help me out here or give me some talking points to explain this to my superiors, it would be appreciated. This seems like it must be a common scenario. Do I need to request for a new raw data format or is there something I can do on my end?
the shift data only looks like this:
id date regular_hours overtime_hours total_hours
abc 2016-06-17 8 0.52 8.52
abc 2016-06-18 7.64 0.83 8.47
abc 2016-06-19 7.87 0.23 8.1
the event data is more detailed (30 minute interval data on events handled and the time it took to complete those events in seconds):
id date interval events event_duration
abc 2016-06-17 01:30:00 4 688
abc 2016-06-17 02:00:00 6 924
abc 2016-06-17 02:30:00 10 1320
So, you sum up the event_duration for an entire day and you get a number of seconds which was actually spent doing work. You can then compare this to amount of time that the employee was paid to see how efficient the staffing is.
My concern is that the event data has the date and the time (UTC). The payroll data only has a date without any time zone information. This causes inaccuracies when blending data in Tableau because some shifts cross midnight. Is there a way around this or do I need to propose new data requirements?
(FYI - people have been calculating it just based on the date for years most likely without considering time zones before. My assumption is that they just did not realize that this could cause inaccurate results)

How to select all mondays (or any weekday combination, e.g.: MTW, WTTh, etc.) between two given dates in MySQL?

What I see over the internet is just counting how many days occur whenever you input the day of the week you need. Like between May 1 to May 31, how many mondays are there in it. What I need is to display the dates where it is monday between two given dates. I don't have any code for this now since I don't really know where to start as I've scanned already the MySQL docu but I haven't seen anything useful besides
WEEKDAY('1998-02-03 22:23:00')
or
DAYOFWEEK('1998-02-03')
which shows the day index of a certain date. (but this time, of course, I don't know which dates fall on Mondays., i need the reverse thing)
I need is when I need mondays and tuesdays in february, it will return the following:
2015-02-02
2015-02-03
2015-02-09
2015-02-10
2015-02-16
2015-02-17
2015-02-23
2015-02-24
I dont have any code to display since my progresses in mysql on our proj isn't directly related to this one I'm needing. This is another independent mysql query of our proj I'm trying to get done..

How do I Loop through a schedule in Crystal Reports

I'm building a report in Crystal Reports 2008. The report is dealing with employee's schedules. There are time slots where the schedule is open, and time slots where the schedule is unavailable.
Currently, I've built my logic so that it finds the start and end of an unavailable time. The report them tells me how many hours that particular staff person was unavailable.
My issue is that sometimes, staff people have a block at the beginning of their schedule marked as 'unavailable', and a block at the end of the day as 'unavailable', but between the two they are 'open'. Thus, the report says that particular staff person was out the whole day, but they actually worked. It isn't an option to tell these particular staff people how to schedule their day - they decide their own schedule, and I write the report to accomodate their needs.
SCHEDULE_TIME EMP_ID UNAVAILABLE_CODE WORK_LENGTH
7/5/2011 11:00 100 NULL 15
7/5/2011 11:15 100 NULL 15
7/5/2011 11:30 100 NULL 15
7/5/2011 11:45 100 NULL 15
7/5/2011 12:00 100 15 5
7/5/2011 17:00 100 15 5
This example shows how somebody would have a 5 hour block calculated for unavailable time, but it's only 2 appointments. For the code, I'm using DATEDIFF between appointment times.
(Essentially, they have built in more than one 'unavailable' block, and my logic will only accomodate one 'unavailable' block per day).
I'm pretty sure that I need to run a type of DO...WHILE loop within the report in order to calculate the total hours unavailable. I'm just not sure how to structure the loop in Crystal Reports.
Maybe i'm missing something but what you want to do looks straight forward. Two obvious options:
Running total:
Set the field to {TABLE.WORK_LENGTH}
Set the type to sum
Set the evaluation formula to not(isnull({TABLE.UNAVAILABLE_CODE}))
Set the reset on change of group/field {TABLE.EMP_ID} (assuming you're looking for totals per employee)
Formula/sum:
Create a formula field unavailable_time with if not(isnull({TABLE.UNAVAILABLE_CODE})) then {TABLE.WORK_LENGTH} else 0
Create a group on {TABLE.EMP_ID}
Create a sum on your formula field in the group footer