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
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
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
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 285 members 2,955 guests
Please welcome our newest community members: