I have a time field in seconds (where the seconds is always greater than 86400) and I've been using the following formula to display the time in HH:mm:ss in a Tablix:
=Floor(Sum(Fields!SecondsField.Value) / 3600) & ":" &
Format(DateAdd("s", Sum(Fields!SecondsField.Value), "00:00"), "mm:ss")
When I try to plot this field using a bar chart (and using the same formula for the series formula), no data is displayed and was wondering if you had any ideas how to get around this?
Ideally this time field will be on the Y-axis.
Related
I have two Fields:
ACCEPTED_DRIVER_HOUR
DELIVERY_HOUR
18:42:01
18:49:00
In Google Data Studio, these two fields are shown as Text Fields, so what I want to do is:
SUM(ACCEPTED_DRIVER_HOUR) - SUM (DELIVERY_HOUR)
This way, I can get how much time the driver took to deliver and order.
The problem is that Google Data Studio says that I can't do that because the field is Text and if I change to Number, it says NULL because the numbers have : between them; if I try to change to Date Hour it's not possible.
I already tried to create new fields using CAST and it shows the same error (NULL)
0) Summary
Use EITHER #1 or #2; If #1 (DATETIME_DIFF) doesn't seem to work, try #2 (CAST & RegEx)
1) DATETIME_DIFF
One way that it can be achieved is by creating Date Time fields and then using the DATETIME_DIFF function to find the difference in SECOND after which the type can be set to Duration (sec.); it can be achieved in a single Calculated Field as shown below where the Date used is 01 Jan 1970 (feel free to change the date as required, though ensure that both line 2 and line 3 below use the same date):
1.1) Calculated Field (Formula)
DATETIME_DIFF(
PARSE_DATETIME("%F%T", CONCAT("1970-01-01 ", DELIVERY_HOUR)),
PARSE_DATETIME("%F%T", CONCAT("1970-01-01 ", ACCEPTED_DRIVER_HOUR)),
SECOND)
1.2) Calculated Field (Type)
Numeric > Duration (sec.)
1.3) Calculated Field (Aggregation)
It's set to SUM by default, though it can be changed as required, e.g. AVG.
Editable Google Data Studio Report and a GIF to elaborate:
2) CAST & RegEx
2.1) Calculated Field (Formula)
(CAST(REGEXP_EXTRACT(DELIVERY_HOUR, "^([^:]+):") AS NUMBER)*60*60 +
CAST(REGEXP_EXTRACT(DELIVERY_HOUR, ":([^:]+):") AS NUMBER)*60 +
CAST(REGEXP_EXTRACT(DELIVERY_HOUR, ":(\\d+)$") AS NUMBER)) -
(CAST(REGEXP_EXTRACT(ACCEPTED_DRIVER_HOUR, "^([^:]+):") AS NUMBER)*60*60 +
CAST(REGEXP_EXTRACT(ACCEPTED_DRIVER_HOUR, ":([^:]+):") AS NUMBER)*60 +
CAST(REGEXP_EXTRACT(ACCEPTED_DRIVER_HOUR, ":(\\d+)$") AS NUMBER))
2.2) Calculated Field (Type)
Numeric > Duration (sec.)
2.3) Calculated Field (Aggregation)
It's set to SUM by default, though it can be changed as required, e.g. AVG.
Added a New Page to the Editable Google Data Studio Report and a GIF to demonstrate:
I have Begin Date and End Date in my data file (Excel), then in PowerQuery I add a column where I simply subtract the Begin Date from End Date to create a new column "Import Time", change the result's data type to Duration and in PowerQuery, the column correctly shows the difference expressed in Day:Hour:Minute:Seconds. However, in a report, I need to show the average not of an entire column, but of groups of values in a matrix based on the entire table. In other words, I'm looking for a table that shows columns for Category Name, Avg. Duration and Max Duration, with rows showing the results for each unique Category.
The problem is that when I drag a table field in to the Visualizations Value area and change to Average, it expresses the result as a decimal, and I can't figure out how to show the date / time equivalent. I thought I might have to multiply by 3,600 since the result might be shown in milliseconds, but that didn't work. Any thoughts?
So I theorized that perhaps the issue wasn't one with Power BI, but perhaps with how Microsoft expresses date / time computations. I edited my Excel file that contains the source data and computed the "Import Time" by subtracting Begin Time from End Time. By default, it displays in date / time format of "hh:mm:ss.0000". I then asked Google and came across a simple explanation: to express a date / time in numeric format, you need to multiply the date / time by 24 (hours), 60 (minutes) and 60 (seconds) if that's how you wanted to express the result. I then created a Pivot Table summarizing the average of the Import Times and saw the same thing I did in my Power BI report, which is when it clicked it for me.
To solve the issue, I edited my Power Query step to compute the import time and included " * 24 * 60 * 60" in the formula. After updating the report, the results matched what I saw in Excel and I'm good. Hopefully this helps others to deal with this vexing issue.
You wrap your averaging measure in a FORMAT function to convert it to precisely the text format you want to show in your matrix. For example, suppose your raw output is
Group AvgDuration
------------------
A 0.0633
B 0.2733
C 0.0600
These numbers are in the unit of days, so you can convert to hours, minutes, or seconds like this e.g.:
FORMAT ( [AvgDuration] * 24, "0.00h" )
FORMAT ( [AvgDuration] * 24 * 60, "#,0m" )
FORMAT ( [AvgDuration] * 24,* 60 * 60, "#,0s" )
FORMAT ( [AvgDuration], "hh:mm:ss" )
(where [AvgDuration] is your measure you use to calculate the average)
Those last two should look like this:
Group AvgDuration
------------------
A 5,472s
B 23,616s
C 5,184s
and
Group AvgDuration
------------------
A 01:31:12
B 06:33:36
C 01:26:24
I need to calculate the difference between the time a patient arrives for their appointment, and the time they check out, also displaying the default length of their appointment, THEN show the percentage of their default appointment time that was actually used.
I've calculated the first part:
,TRUNC(24*MOD(enc.CHECKOUT_TIME - enc.CHECKIN_TIME,1))|| ':' ||TRUNC(MOD(MOD(enc.CHECKOUT_TIME - enc.CHECKIN_TIME,1)*24,1)*60) AS "VISIT LENGTH"
The default appointment duration is in this field: enc.APPT_LENGTH. This is the part I'm not sure how to do - calculate the percentage of the APPT_LENGTH that was actually used (VISIT_LENGTH) as calculated by the above.
Thanks in advance for any assistance.
Your question is not very clear but, to get the actual duration of an appointment in hours (decimal system), you can use:
(enc.CHECKOUT_TIME - enc.CHECKIN_TIME) * 24 AS ACTUAL_DURATION
since using - with 2 dates in Oracle results in the difference in days between the 2 dates.
Now, if APPT_LENGTH contains the expected duration of the appointment in hours too, you can then use
(((enc.CHECKOUT_TIME - enc.CHECKIN_TIME) * 24) / enc.APPT_LENGTH) * 100 AS DURATION_RATIO
to calculate the ratio (in %) between the actual duration and the expected duration
The current report expression presents the data in Days:Hours:Minutes:Seconds
=cstr(floor((sum(Fields!phoneInOutbound.Value) / 86400))) & " days " &
cstr(floor(((sum(Fields!phoneInOutbound.Value) Mod 86400) / 3600))) & ":" &
cstr(floor((((sum(Fields!phoneInOutbound.Value) Mod 86400) Mod 3600) / 60))) & ":" &
cstr(floor(((sum(Fields!phoneInOutbound.Value) Mod 86400) Mod 3600) Mod 60))
I am trying to get it to show total Hours:Minutes:Seconds.
So far I have only managed to get minutes:seconds using the following expression;
=cstr(floor((sum(Fields!phoneInOutbound.Value) / 60))) & " : " &
cstr(floor(((sum(Fields!phoneInOutbound.Value) Mod 60))))
Any idea how to reconfigure so I can get total hours:minutes:seconds?
Okay so your basically going to need to add the first statement (Where it originally gets days) plus the second statement (where it was originally hours). You can either change the first statement to get the days than days * 24 to get days back to hours THAN + 2nd statement. There's probably an easier way, not sure what your data set looks like or even what database your reading from. Just trying to get you thinking in the right direction.
If I was you I would handle it on sql side and just use ssrs as a place to hold the data. You can make this as easy or as complex you want. When I mean complex i mean you get the data from Minutes filed and then add "min" + seconds value + "sec" to it. By wrapping the whole thing in another named query and creating a calculated field. Personally not a big fan of leveraging SSRS for doing calculations as you are using report server's memory to do this (which should be used for reporting not handling calculations) BUT if this method is easy for you then more power to ya. Below is a sample code to handle this on SQL side.
create table #temp_time_test (
phoneInOutbound_IN datetime
,phoneInOutbound_OUT datetime
)
insert into #temp_time_test values
('11/06/2018 12:24:13.790','11/06/2018 12:34:13.790')
select DATEDIFF(MINUTE,phoneInOutbound_IN,phoneInOutbound_OUT) from #temp_time_test
I'm trying to apply a duration format to some cells in google spreadsheet. I would like to convert an integer number in a format: X days x hours x minutes.
I've tried with some formats like: d:h:mm but i found a problem when I apply the format. It always put one day less. When I write 1 in the cell the convert to 31:0:00. When I write 2 the cells changes to 1:00:00.
That is because the duration format is actually a date / time format (for comparing dates).
If you simply enter a number (1) google will interpret that as midnight (as times are stored as fractions of whole days) of the reference day number 1.
Reference day in Google Sheets is 31/12/1899 - IE the 31st day of the month. That is why your result returns days=31.
To achieve what you want you effectively want to add 1 to your values. so that 1 (+1) actually becomes "2 days since 31/12/1899 - ie 01/01/1900 - ie 1 day, and you could then use custom format for display, but this wont work when you have >31 days.
I think the best way is to simply concatenate the data you have with relavent parts like so (where A1 is a cell containg your data - 1,2,1.5 etc):
=int(A1)&" days "&int(MOD(A1,1)*24)&" hours " & mod(MOD(A1,1)*24,1)*60 & " minutes"