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.
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.
Solved! Go to Solution.
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
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
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 |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |