Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

Halfhourly Timestamps in a Chart

$
0
0

One of my colleagues had an interesting requirement (and I'm pretty sure many users might've), to show halfhourly timestamps in a chart, so they can show number of calls received to report issues every half hour (in a day) vs how many of them were resolved . I saw at least one discussion in SCN Webi, where someone used Formatdate([Datetimestamp];"hhmm") to convert timestamp into hour:minutes and then create a halfhourly bucket. I'm following a different way, convert timestamp to a numeric value and then, create 48 different halfhourly datetimestamp buckets, which will work perfect up to seconds.

 

Below is the data that we'll be using during this exercise:

 

Date TimestampCalls ReceivedCalls Resolved
6/12/2016 12:00:01 AM98
6/12/2016 12:15:00 AM21
6/12/2016 12:30:00 AM32
6/12/2016 12:45:00 AM32
6/12/2016 1:00:00 AM43
6/12/2016 1:15:00 AM54
6/12/2016 1:30:00 AM76
6/12/2016 1:45:00 AM32
6/12/2016 2:00:00 AM87
6/12/2016 2:15:00 AM43
6/12/2016 2:30:00 AM76
6/12/2016 2:45:00 AM76
6/12/2016 3:00:00 AM32
6/12/2016 3:15:00 AM65
6/12/2016 3:30:00 AM65
6/12/2016 3:45:00 AM75
6/12/2016 4:00:00 AM31
6/12/2016 4:15:00 AM20
6/12/2016 4:30:00 AM42
6/12/2016 4:45:00 AM86
6/12/2016 5:00:00 AM42
6/12/2016 5:15:00 AM86
6/12/2016 5:30:00 AM42
6/12/2016 5:45:00 AM75
6/12/2016 6:00:00 AM86
6/12/2016 6:15:00 AM41
6/12/2016 6:30:00 AM52
6/12/2016 6:45:00 AM41
6/12/2016 7:00:00 AM41
6/12/2016 7:15:00 AM85
6/12/2016 7:30:00 AM40
6/12/2016 7:45:00 AM73
6/12/2016 8:00:00 AM51
6/12/2016 8:15:00 AM51
6/12/2016 8:30:00 AM62
6/12/2016 8:45:00 AM84
6/12/2016 9:00:00 AM40
6/12/2016 9:15:00 AM84
6/12/2016 9:30:00 AM40
6/12/2016 9:45:00 AM84
6/12/2016 10:00:00 AM43
6/12/2016 10:15:00 AM76
6/12/2016 10:30:00 AM43
6/12/2016 10:45:00 AM43
6/12/2016 11:00:00 AM54
6/12/2016 11:15:00 AM87
6/12/2016 11:30:00 AM32
6/12/2016 11:45:00 AM32
6/12/2016 12:00:00 PM65
6/12/2016 12:15:00 PM43
6/12/2016 12:30:00 PM76
6/12/2016 12:45:00 PM51
6/12/2016 1:00:00 PM73
6/12/2016 1:15:00 PM73
6/12/2016 1:30:00 PM73
6/12/2016 1:45:00 PM62
6/12/2016 2:00:00 PM32
6/12/2016 2:15:00 PM76
6/12/2016 2:30:00 PM32
6/12/2016 2:45:00 PM65
6/12/2016 3:00:00 PM32
6/12/2016 3:15:00 PM76
6/12/2016 3:30:00 PM32
6/12/2016 3:45:00 PM76
6/12/2016 4:00:00 PM31
6/12/2016 4:15:00 PM75
6/12/2016 4:30:00 PM31
6/12/2016 4:45:00 PM75
6/12/2016 5:00:00 PM64
6/12/2016 5:15:00 PM64
6/12/2016 5:30:00 PM20
6/12/2016 5:45:00 PM75
6/12/2016 6:00:00 PM64
6/12/2016 6:15:00 PM42
6/12/2016 6:30:00 PM75
6/12/2016 6:45:00 PM53
6/12/2016 7:00:00 PM72
6/12/2016 7:15:00 PM72
6/12/2016 7:30:00 PM32
6/12/2016 7:45:00 PM61
6/12/2016 8:00:00 PM32
6/12/2016 8:15:00 PM72
6/12/2016 8:30:00 PM33
6/12/2016 8:45:00 PM61
6/12/2016 9:00:00 PM33
6/12/2016 9:15:00 PM72
6/12/2016 9:30:00 PM32
6/12/2016 9:45:00 PM72
6/12/2016 10:00:00 PM32
6/12/2016 10:15:00 PM76
6/12/2016 10:30:00 PM32
6/12/2016 10:45:00 PM76
6/12/2016 11:00:00 PM64
6/12/2016 11:15:00 PM65
6/12/2016 11:30:00 PM20
6/12/2016 11:45:00 PM64
6/12/2016 11:59:59 PM92


Step 1:

Create the below Dimension variables

  • v_Date TimeStamp =ToDate(FormatDate([Date Timestamp];"M/d/yyyy HH:mm:ss");"M/d/yyyy HH:mm:ss")(to convert the Date Timestamp to 24 hr format) 
  • v_Hours =ToNumber(FormatDate([DateTimeStamp];"HH")) (to get the Hour in 24 hr format in numeric datatype, we want it to be 24 hr format, so we don't have to worry about AM or PM)
  • v_Minutes =ToNumber(FormatDate([DateTimeStamp];"mm")) (to get the mins in numeric datatype)
  • v_Seconds =ToNumber(FormatDate([DateTimeStamp];"ss")) (to get the seconds datatype)
  • v_Numeric Value =([v_Hours]*3600)+([v_Minutes]*60)+[v_Seconds] (this creates a numeric value for every sec of the day (0 - 86399), as a day has 86400 secs, logic is simple, multiple Hours by 3600 as an hour has 3600 secs, multiple Minutes by 60 as a minute has 60 secs and add the Seconds)

Now, main variable of this logic

  • v_Halfhourly Timestamps

=If([v_Numeric Value]  Between  (0;1799))  Then  "00:00:00"

ElseIf([v_Numeric Value]  Between  (1800;3599))  Then  "00:30:00"

ElseIf([v_Numeric Value]  Between  (3600;5399))  Then  "01:00:00"

ElseIf([v_Numeric Value]  Between  (5400;7199))  Then  "01:30:00"

ElseIf([v_Numeric Value]  Between  (7200;8999))  Then  "02:00:00"

ElseIf([v_Numeric Value]  Between  (9000;10799))  Then  "02:30:00"

ElseIf([v_Numeric Value]  Between  (10800;12599))  Then  "03:00:00"

ElseIf([v_Numeric Value]  Between  (12600;14399))  Then  "03:30:00"

ElseIf([v_Numeric Value]  Between  (14400;16199))  Then  "04:00:00"

ElseIf([v_Numeric Value]  Between  (16200;17999))  Then  "04:30:00"

ElseIf([v_Numeric Value]  Between  (18000;19799))  Then  "05:00:00"

ElseIf([v_Numeric Value]  Between  (19800;21599))  Then  "05:30:00"

ElseIf([v_Numeric Value]  Between  (21600;23399))  Then  "06:00:00"

ElseIf([v_Numeric Value]  Between  (23400;25199))  Then  "06:30:00"

ElseIf([v_Numeric Value]  Between  (25200;26999))  Then  "07:00:00"

ElseIf([v_Numeric Value]  Between  (27000;28799))  Then  "07:30:00"

ElseIf([v_Numeric Value]  Between  (28800;30599))  Then  "08:00:00"

ElseIf([v_Numeric Value]  Between  (30600;32399))  Then  "08:30:00"

ElseIf([v_Numeric Value]  Between  (32400;34199))  Then  "09:00:00"

ElseIf([v_Numeric Value]  Between  (34200;35999))  Then  "09:30:00"

ElseIf([v_Numeric Value]  Between  (36000;37799))  Then  "10:00:00"

ElseIf([v_Numeric Value]  Between  (37800;39599))  Then  "10:30:00"

ElseIf([v_Numeric Value]  Between  (39600;41399))  Then  "11:00:00"

ElseIf([v_Numeric Value]  Between  (41400;43199))  Then  "11:30:00"

ElseIf([v_Numeric Value]  Between  (43200;44999))  Then  "12:00:00"

ElseIf([v_Numeric Value]  Between  (45000;46799))  Then  "12:30:00"

ElseIf([v_Numeric Value]  Between  (46800;48599))  Then  "13:00:00"

ElseIf([v_Numeric Value]  Between  (48600;50399))  Then  "13:30:00"

ElseIf([v_Numeric Value]  Between  (50400;52199))  Then  "14:00:00"

ElseIf([v_Numeric Value]  Between  (52200;53999))  Then  "14:30:00"

ElseIf([v_Numeric Value]  Between  (54000;55799))  Then  "15:00:00"

ElseIf([v_Numeric Value]  Between  (55800;57599))  Then  "15:30:00"

ElseIf([v_Numeric Value]  Between  (57600;59399))  Then  "16:00:00"

ElseIf([v_Numeric Value]  Between  (59400;61199))  Then  "16:30:00"

ElseIf([v_Numeric Value]  Between  (61200;62999))  Then  "17:00:00"

ElseIf([v_Numeric Value]  Between  (63000;64799))  Then  "17:30:00"

ElseIf([v_Numeric Value]  Between  (64800;66599))  Then  "18:00:00"

ElseIf([v_Numeric Value]  Between  (66600;68399))  Then  "18:30:00"

ElseIf([v_Numeric Value]  Between  (68400;70199))  Then  "19:00:00"

ElseIf([v_Numeric Value]  Between  (70200;71999))  Then  "19:30:00"

ElseIf([v_Numeric Value]  Between  (72000;73799))  Then  "20:00:00"

ElseIf([v_Numeric Value]  Between  (73800;75599))  Then  "20:30:00"

ElseIf([v_Numeric Value]  Between  (75600;77399))  Then  "21:00:00"

ElseIf([v_Numeric Value]  Between  (77400;79199))  Then  "21:30:00"

ElseIf([v_Numeric Value]  Between  (79200;80999))  Then  "22:00:00"

ElseIf([v_Numeric Value]  Between  (81000;82799))  Then  "22:30:00"

ElseIf([v_Numeric Value]  Between  (82800;84599))  Then  "23:00:00"

ElseIf([v_Numeric Value]  Between  (84600;86399))  Then  "23:30:00"

 

Step 2:

  1. Create a Column Chart, with v_Halfhourly Timestamps on Category axis (X axis), Calls Received and Calls Resolved on Value Axis 1.
  2. Go to Format Chart -> Value Axis -> in Stacking, select Unstacked
  3. Go to Format Chart -> Plot Area -> Design -> update Spacing within Groups as 0.1 and Spacing between Groups to 0.5, that'll make the bars for Calls Received and Calls Resolved for a timestamp look close to each other, which looks nice to compare the 2 values. Apply and OK.
  4. In addition to that, Format Data Series of Calls Received as Red color and Calls Resolved as Green color.

 

Voila, we did it. This is what the chart looks like, now.

Snap 01.png

 

Please try it and let me know your feedback, so I can fix if there are any issues or improve it further.


Thanks,
Mahboob Mohammed


Viewing all articles
Browse latest Browse all 2548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>