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,
First let me give some context to the problem.
I have a roster table which specifies the details about 12 hr rostered shifts. start time (in local and UTC), finish time, whether day shift/night shift and so on. The business views a completed day for reporting purposes as when the day shift AND the night shift completes. Note that the night shift finishes on the morning of the next day.
So i'm trying to create the calculated column syntax that can take the current time when the dataset refreshes (eg UTCNOW) and from that time value work out where you are in that roster table by comparing that time to the shift start and end dates.
Once i can do that successfully then it enables a few columns to be created for things like :
isListShift : identifies that last completed shift compared to dateset refresh time
isLastDay : identifies the last completed "Day" compared to dataset refresh time
isMTD : identifies the rows that contribute to MTD calculation*
* MTD : the nuance here is that on the first of the month the MTD is the prior month as you are currently in a day that hasn't completed yet. (I can't use the relative date filtering in the pbi service as that works on UTC and as AU is ahead in time, the new month starts on UTC Jul 31 20:00 and finishes on UTC Aug 1 8:00 so when it clicks over to the 1st the relative date filter of "is in this month" switches to the new month. It needs to b epinned to Aug and not switch to Sep until local Day 2 of the month starts.
I know this sounds like a christopher nolan time travel film....
I have somethign working with layered if statements but i'm sure there is a smarter pattern.
The table is used as a "date" table via relationship to fact tables.
A subset of the roster table is pasted below.
My current calculated column is also below.
id | ShiftIndex | Date | DateCode | Shift | UTC_Shift_Start | Shift_Start | UTC_Shift_End | Shift_End |
32518 | 202007241 | 24/07/2020 | 20200724 | Day | 23/07/2020 20:00 | 24/07/2020 6:00 | 24/07/2020 8:00 | 24/07/2020 18:00 |
32519 | 202007242 | 24/07/2020 | 20200724 | Night | 24/07/2020 8:00 | 24/07/2020 18:00 | 24/07/2020 20:00 | 25/07/2020 6:00 |
32520 | 202007251 | 25/07/2020 | 20200725 | Day | 24/07/2020 20:00 | 25/07/2020 6:00 | 25/07/2020 8:00 | 25/07/2020 18:00 |
32521 | 202007252 | 25/07/2020 | 20200725 | Night | 25/07/2020 8:00 | 25/07/2020 18:00 | 25/07/2020 20:00 | 26/07/2020 6:00 |
32522 | 202007261 | 26/07/2020 | 20200726 | Day | 25/07/2020 20:00 | 26/07/2020 6:00 | 26/07/2020 8:00 | 26/07/2020 18:00 |
32523 | 202007262 | 26/07/2020 | 20200726 | Night | 26/07/2020 8:00 | 26/07/2020 18:00 | 26/07/2020 20:00 | 27/07/2020 6:00 |
32524 | 202007271 | 27/07/2020 | 20200727 | Day | 26/07/2020 20:00 | 27/07/2020 6:00 | 27/07/2020 8:00 | 27/07/2020 18:00 |
32525 | 202007272 | 27/07/2020 | 20200727 | Night | 27/07/2020 8:00 | 27/07/2020 18:00 | 27/07/2020 20:00 | 28/07/2020 6:00 |
32526 | 202007281 | 28/07/2020 | 20200728 | Day | 27/07/2020 20:00 | 28/07/2020 6:00 | 28/07/2020 8:00 | 28/07/2020 18:00 |
32527 | 202007282 | 28/07/2020 | 20200728 | Night | 28/07/2020 8:00 | 28/07/2020 18:00 | 28/07/2020 20:00 | 29/07/2020 6:00 |
32528 | 202007291 | 29/07/2020 | 20200729 | Day | 28/07/2020 20:00 | 29/07/2020 6:00 | 29/07/2020 8:00 | 29/07/2020 18:00 |
32529 | 202007292 | 29/07/2020 | 20200729 | Night | 29/07/2020 8:00 | 29/07/2020 18:00 | 29/07/2020 20:00 | 30/07/2020 6:00 |
32530 | 202007301 | 30/07/2020 | 20200730 | Day | 29/07/2020 20:00 | 30/07/2020 6:00 | 30/07/2020 8:00 | 30/07/2020 18:00 |
32531 | 202007302 | 30/07/2020 | 20200730 | Night | 30/07/2020 8:00 | 30/07/2020 18:00 | 30/07/2020 20:00 | 31/07/2020 6:00 |
32532 | 202007311 | 31/07/2020 | 20200731 | Day | 30/07/2020 20:00 | 31/07/2020 6:00 | 31/07/2020 8:00 | 31/07/2020 18:00 |
32533 | 202007312 | 31/07/2020 | 20200731 | Night | 31/07/2020 8:00 | 31/07/2020 18:00 | 31/07/2020 20:00 | 1/08/2020 6:00 |
32534 | 202008011 | 1/08/2020 | 20200801 | Day | 31/07/2020 20:00 | 1/08/2020 6:00 | 1/08/2020 8:00 | 1/08/2020 18:00 |
32535 | 202008012 | 1/08/2020 | 20200801 | Night | 1/08/2020 8:00 | 1/08/2020 18:00 | 1/08/2020 20:00 | 2/08/2020 6:00 |
32536 | 202008021 | 2/08/2020 | 20200802 | Day | 1/08/2020 20:00 | 2/08/2020 6:00 | 2/08/2020 8:00 | 2/08/2020 18:00 |
32537 | 202008022 | 2/08/2020 | 20200802 | Night | 2/08/2020 8:00 | 2/08/2020 18:00 | 2/08/2020 20:00 | 3/08/2020 6:00 |
32538 | 202008031 | 3/08/2020 | 20200803 | Day | 2/08/2020 20:00 | 3/08/2020 6:00 | 3/08/2020 8:00 | 3/08/2020 18:00 |
32539 | 202008032 | 3/08/2020 | 20200803 | Night | 3/08/2020 8:00 | 3/08/2020 18:00 | 3/08/2020 20:00 | 4/08/2020 6:00 |
@frano72 - I'm not certain what you want as your end result. Given your sample data, what would your end result look like? If you are using nested IF statements, a better pattern is SWITCH(TRUE()...)
Hi @Greg_Deckler,
I'm basically after a column that has a 1 or a 0 in it which I can then use as a filter and could be called CurrenReportingMonth
The simplistic logic is :
if the dataset refreshed at anytime during the 2 x 12 hour shifts that are considered the first of the month (eg Aug 1st) - then each row for July has a 1 in it, 0's every where else. As soon as we exit Aug 1st and are in Aug 2, then there are 1s for all rows for August.
I need to be able to compare refresh time (UTCNOW) with the two shiftstart, shiftend columns in the roster table to determine the current day/month combo and then use that to then calculate for each row whether its a 1 or 0.
So first step to sovle is how to find UTCNOW between two columns of dates and return a value from another column for that row.
thanks !
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 |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |