cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
runelynxAPMT New Member
New Member

Shifted Start Date with Year to Date Since Inception

Hi all,

I'm new to Power BI and am trying to transform date data (sourced from SQL Server) according to the shift scheme we use. For propery reporting to my users, I need to determine which shift data falls into, and usually only report data for the current shift. The logic below has worked for me in SQL but I am pretty lost in where to begin with Power BI. I don't see how I can use the standard features of columns with "IF" kind of logic. Can anyone point me in the right direction?

 

>If the timestamp's hour is midnight through 3am, then the shift date is "date - 1" (2nd shift runs 6pm - 3am so Wednesday 2am is really part of Tuesday 2nd shift)

>If the hour is 6am - 5pm, then shift = 1st. If the hour is 6pm - 3am, then shift = 2nd.

>If the timestamp is within the last 8 hours & the shift = shift determined from current time, then current shift = true.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Shifted Start Date with Year to Date Since Inception

Hi @runelynxAPMT ,

I share a sample measure formula to mark your shift date and index, you can try it if it works on your side:

Shift Index =
VAR _currDate =
    MAX ( Table[timestamp] )
VAR _shiftIndex =
    IF ( HOUR ( _currDate ) >= 6 && HOUR ( _currDate ) <= 17, "1st", "2nd" )
VAR _shitfDate =
    IF ( HOUR ( _currDate ) <= 3, _currDate - 1, _currDate )
RETURN
    _shitfDate & " " & _shiftIndex

I'm not so clarify for your condition #3, can you please explain more about this?
In addition, if above not help, please provide some sample data to help us clarify your data structure and test to coding formula.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

1 REPLY 1
Highlighted
Community Support Team
Community Support Team

Re: Shifted Start Date with Year to Date Since Inception

Hi @runelynxAPMT ,

I share a sample measure formula to mark your shift date and index, you can try it if it works on your side:

Shift Index =
VAR _currDate =
    MAX ( Table[timestamp] )
VAR _shiftIndex =
    IF ( HOUR ( _currDate ) >= 6 && HOUR ( _currDate ) <= 17, "1st", "2nd" )
VAR _shitfDate =
    IF ( HOUR ( _currDate ) <= 3, _currDate - 1, _currDate )
RETURN
    _shitfDate & " " & _shiftIndex

I'm not so clarify for your condition #3, can you please explain more about this?
In addition, if above not help, please provide some sample data to help us clarify your data structure and test to coding formula.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

Helpful resources

Announcements
New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (3,505)