Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |