I have a timestamp label column (mm/dd/yyyy h:mm:ss) that I need to use to identify what shift it took place. I am connected to a server and cannot adjust the timestamp format or create columns. I need to create a measure to label the shifts. The shifts are
1a: 7:00am - 10:20am
2a: 10:20am - 1:30pm
3a: 1:30pm - 4:50pm
4a: 4:50pm - 7:00pm
1b: 7:00pm - 10:20pm
2b: 10:20pm - 1:30am
3b: 1:30am - 4:50am
4b: 4:50am - 7:00am
I've seen similar questions asked here, but they all seem to be for adding a column and not a measure. Thanks in advance.
You can either use a disconnected table or a SWITCH(TRUE() measure like the one below to do that. For vDT, use your expression to get the datetime value from your column.
Shift =
VAR vDT =
MAX ( T2[DT] )
VAR vThisTime =
TIME ( HOUR ( vDT ), MINUTE ( vDT ), 0 )
VAR vResult =
SWITCH (
TRUE (),
vThisTime >= TIME ( 7, 0, 0 )
&& vThisTime < TIME ( 10, 20, 0 ), "1a",
vThisTime >= TIME ( 10, 20, 0 )
&& vThisTime < TIME ( 13, 30, 0 ), "2a",
vThisTime >= TIME ( 13, 30, 0 )
&& vThisTime < TIME ( 16, 50, 0 ), "3a",
vThisTime >= TIME ( 16, 50, 0 )
&& vThisTime < TIME ( 19, 00, 0 ), "4a",
vThisTime >= TIME ( 19, 0, 0 )
&& vThisTime < TIME ( 22, 20, 0 ), "1b",
vThisTime >= TIME ( 22, 20, 0 )
&& vThisTime < TIME ( 1, 30, 0 ), "2b",
vThisTime >= TIME ( 1, 30, 0 )
&& vThisTime <= TIME ( 4, 50, 0 ), "3b",
"4b"
)
RETURN
vResult
Pat
Thank you! Here's what I ended up doing -
First, I created a measure to pull the time out of the date/time column.
Then used
Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.
Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!
Join the biggest FREE Business Applications Event in LATAM this February.
User | Count |
---|---|
216 | |
57 | |
49 | |
46 | |
45 |
User | Count |
---|---|
267 | |
211 | |
113 | |
82 | |
71 |