Case Study: Converting Seconds to Regular Time

This case study focuses on creating a calculated measure to convert seconds to regular time in an Ad Hoc view in Lambda Analytics.

All Time Spent Learning data in your Moodle or Totara database is stored as seconds. To create reader-friendly reports, it would be best to create a calculated field that converts raw seconds to the "HH:MM:SS" (hours-minutes-seconds) format that we are used to reading. 

Using the New Calculated Measure window in the Ad Hoc editor, you can create a calculated measure to convert field data stored in raw seconds to regular time. For the purposes of this case study, we will convert the mdl_local_id_course.totaldedication field to a regular time format.

important-2  NOTE

This walkthrough assumes that you have opened a new Ad Hoc view in the Ad Hoc editor from the Course Dedication data source.

1.  In the Measures panel of the Ad Hoc editor, hover over the title bar menu.

2.  Select Create Calculated Measure to open the New Calculated Measure window.

3.  In the Measure Name field, enter a name for your new calculated measure. We will call our new measure "Total Time Spent."

4.  From the Functions list, double-click the FormatTime function. "FormatTime ("NumberFieldName")" will appear in the Formula box.

5.  In the Formula box, highlight the text "NumberFieldName."

6.  From the Fields and Measures list, find and double-click the Course Total Dedication measure. The name of this measure will replace the highlighted text in the formula box.

"Course Total Dedication" is the defined display label for mdl_local_id_course.totaldedication in the Course Dedication data source.

7.  When creating calculated measures, you should always click Validate to ensure that your field is logical and operative. If no errors are discovered, a success message will appear next to the button of the New Calculated Measure window. 

8.  Click Create Measure to add the new calculated measure to the Measures panel in the Ad Hoc editor. "Total Time Spent" now appears in the Measures list, and can be added to the Ad Hoc view in the same manner as any other measure or field.