How to do it...

To implement this recipe, do the following:

  1. Create a new table with the following formula:
R01_12-Hour_Clock = 
VAR __hours =
SELECTCOLUMNS(
GENERATESERIES(1 , 12 , 1),
"Hour",
[Value]
)
VAR __minutes =
SELECTCOLUMNS(
GENERATESERIES(0 , 59 , 1),
"Minutes",
[Value]
)
VAR __seconds =
SELECTCOLUMNS(
GENERATESERIES(0 , 59 , 1),
"Seconds",
[Value]
)
VAR __period =
SELECTCOLUMNS(
{ ("AM"),("PM") },
"AM/PM",
[Value]
)
VAR __hoursMinutes = GENERATEALL(__hours, __minutes)
VAR __hoursMinutesSeconds = GENERATEALL(__hoursMinutes,__seconds)
VAR __hoursMinutesSecondsAMPM = GENERATEALL(__hoursMinutesSeconds,__period)
VAR __final =
SELECTCOLUMNS(
ADDCOLUMNS(
__hoursMinutesSecondsAMPM,
"Time",
TIMEVALUE(
FORMAT([Hour],"00") & ":" &
FORMAT([Minutes],"00") & ":" &
FORMAT([Seconds],"00") & " " & [AM/PM]
)
),
"Time",
[Time]
)
RETURN
__final
  1. In the R01_12-Hour_Clock table, ensure that the Time column is set to have a data type of Time.