Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello All,
I have a Time table that I calculated with the following DAX:
I would like to add a Shift column the states if the time is between these two times it's 1st shift. Or if the time is between these other two times it's 2nd shift. If it's not either of those then there is no shift. Below is the code I'm using:
It correctly gets the first shift but does not get second shift at all.
Any help would be greatly appreciated.
Thanks!
Solved! Go to Solution.
@nleuck_101 this:
Shift =
SWITCH ( TRUE (),
'Time'[TimeandDay] >= TIME ( 8,0,0) && 'Time'[TimeandDay] < TIME(16,30,0), "Shift 1",
( 'Time'[TimeandDay] >= TIME ( 18,30,0) ) || ( 'Time'[TimeAndDay] >= TIME(0,0,0) && 'Time'[TimeAndDay] < TIME (3, 0,0)), "Shift 2",
"Shift 0"
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@nleuck_101 this:
Shift =
SWITCH ( TRUE (),
'Time'[TimeandDay] >= TIME ( 8,0,0) && 'Time'[TimeandDay] < TIME(16,30,0), "Shift 1",
( 'Time'[TimeandDay] >= TIME ( 18,30,0) ) || ( 'Time'[TimeAndDay] >= TIME(0,0,0) && 'Time'[TimeAndDay] < TIME (3, 0,0)), "Shift 2",
"Shift 0"
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@nleuck_101 I have no idea what you are talking about, give the range in plain simple English (NO DAX)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@nleuck_101 See attached, in my opinion, it is working
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k
But 2nd shift cross over into midnight when the time changes. If I use just use >= TIME(18, 30, 0) at midnight it flips back to 0. 2nd shift needs to go through to 3:00am.
@nleuck_101 I think you need this:
SWITCH ( TRUE (),
'Time'[TimeandDay] >= TIME ( 3,0,0) && 'Time'[TimeandDay] < TIME(8,0,0), "Shift 0",
'Time'[TimeandDay] >= TIME ( 8,0,0) && 'Time'[TimeandDay] < TIME(16,30,0), "Shift 1",
'Time'[TimeandDay] >= TIME ( 18,30,0), "Shift 2",
"Shift 0"
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@nleuck_101 can you give me the range of your shifts:
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@nleuck_101 try this:
SWITCH ( TRUE ()
Table[TimeAndDay] >= TIME ( 8,0,0) && Table[TimeAnDay] < TIME(16,0,0), "Shift 1",
Table[TimeAndDay] >= TIME ( 16,0,0) && Table[TimeAnDay] <= TIME(23,59,0), "Shift 2",
"Shift 3"
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k
I've tried changing the times around for 2nd shift and it doesn't work.
@parry2k
It's not working. I'm still on getting 1st Shift and 3rd Shift. It's not picking up the 2nd Shift.
@nleuck_101 you should compare it against timeandday column which is actually time rather than a text column:
SWITCH ( TRUE ()
Table[TimeAndDay] >= TIME ( 8,0,0) && Table[TimeAnDay] < TIME(16,0,0), "Shift 1",
Table[TimeAndDay] >= TIME ( 16,0,0) && Table[TimeAnDay] < TIME(0,0,0), "Shift 2",
"Shift 3"
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
84 | |
77 | |
76 | |
43 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |