cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

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 @Anonymous ,

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, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

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 @Anonymous ,

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, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

Helpful resources

Announcements
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors