Forum Discussion
BZLykke_KAB
3 years agoNew Member
Sort date/time column into time slots in new column
I would like to sort each row in creationDate (see below) into 4 time slots (24h format) into a new column 07:00:00 - 09:59:59 10:00:00 - 12:59:59 13:00:00 - 15:59:59 16:00:00 - 06:59:59 M...
- Anonymous3 years ago
Hi BZLykke_KAB
You can refer to the following column
Range = VAR a = { "07:00:00-09:59:59", "10:00:00-12:59:59", "13:00:00-15:59:59", "16:00:00-06:59:59" } VAR b = ADDCOLUMNS ( a, "lefttime", TIMEVALUE ( LEFT ( [Value], SEARCH ( "-", [Value] ) - 1 ) ), "rightvalur", TIMEVALUE ( MID ( [Value], SEARCH ( "-", [Value] ) + 1, LEN ( [Value] ) - SEARCH ( "-", [Value] ) ) ) ) VAR c = ADDCOLUMNS ( b, "Detaillefttime", IF ( [lefttime] > TIME ( 12, 00, 00 ) && [rightvalur] < TIME ( 12, 00, 00 ), [rightvalur] + 1, [rightvalur] ) ) VAR d = TIMEVALUE ( [Date] ) RETURN MINX ( FILTER ( c, [lefttime] < d && [Detaillefttime] >= d ), [Value] )Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi BZLykke_KAB
You can refer to the following column
Range =
VAR a = {
"07:00:00-09:59:59",
"10:00:00-12:59:59",
"13:00:00-15:59:59",
"16:00:00-06:59:59"
}
VAR b =
ADDCOLUMNS (
a,
"lefttime", TIMEVALUE ( LEFT ( [Value], SEARCH ( "-", [Value] ) - 1 ) ),
"rightvalur",
TIMEVALUE (
MID (
[Value],
SEARCH ( "-", [Value] ) + 1,
LEN ( [Value] ) - SEARCH ( "-", [Value] )
)
)
)
VAR c =
ADDCOLUMNS (
b,
"Detaillefttime",
IF (
[lefttime] > TIME ( 12, 00, 00 )
&& [rightvalur] < TIME ( 12, 00, 00 ),
[rightvalur] + 1,
[rightvalur]
)
)
VAR d =
TIMEVALUE ( [Date] )
RETURN
MINX ( FILTER ( c, [lefttime] < d && [Detaillefttime] >= d ), [Value] )
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BZLykke_KAB
3 years agoNew Member
Great thanks, it took a little while to understand, but managed.
Had to change the array to
"07:00:00-10:00:00",
"10:00:00-13:00:00",
"13:00:00-16:00:00",
"16:00:00-00:00:00",
"00:00:00-07:00:00"
Because some times we're outside eg. 00:59:01 and 12:59:59...
Because some times we're outside eg. 00:59:01 and 12:59:59...