Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I have a single table containing overtime transactions (10s of thousands rows per year). Each overtime transaction is in a separate row. For one specific type of overtime (OT code X), I would like to identify how many times more than 1 person from the same group (ex. East) is doing the same type of overtime on the same day AND at the same time.
Here is a sample of my data (jpeg and Excel). The last column is my expected result.
Here is the formula i have tried which is based upon some other quasi similar posts in the forum (but i realize i may be way off here). Basically this formula returns (mistakenly) that everything is "Yes". I didn't even add in the same time criteria based on the OT start and end time yet but that would be an essential piece of this formula as well.
Any help/guidance would be much appreciated. Thank you in advance.
Solved! Go to Solution.
Sorry, the Excel document did not post for some reason. here is the same table as the picture in the post.
Employee Name | OT Code | Group | Date | Ot start time | Ot end time | Multiple people in same group doing Overtime type x at same time? |
Mr A | X | East | 2019-01-01 | 8:00 | 10:00 | Yes |
Mr B | Z | West | 2019-01-01 | 12:00 | 14:00 | No |
Mr C | X | East | 2019-01-01 | 9:00 | 11:00 | Yes |
Mr A | Z | West | 2019-01-02 | 8:00 | 11:00 | No |
Mr B | Z | West | 2019-01-02 | 8:00 | 12:00 | No |
Mr C | Y | West | 2019-01-02 | 8:00 | 10:00 | No |
Mr A | X | West | 2019-01-03 | 12:00 | 14:00 | Yes |
Mr B | Y | East | 2019-01-03 | 9:00 | 11:00 | No |
Mr C | X | West | 2019-01-03 | 12:00 | 14:00 | Yes |
Sorry, the Excel document did not post for some reason. here is the same table as the picture in the post.
Employee Name | OT Code | Group | Date | Ot start time | Ot end time | Multiple people in same group doing Overtime type x at same time? |
Mr A | X | East | 2019-01-01 | 8:00 | 10:00 | Yes |
Mr B | Z | West | 2019-01-01 | 12:00 | 14:00 | No |
Mr C | X | East | 2019-01-01 | 9:00 | 11:00 | Yes |
Mr A | Z | West | 2019-01-02 | 8:00 | 11:00 | No |
Mr B | Z | West | 2019-01-02 | 8:00 | 12:00 | No |
Mr C | Y | West | 2019-01-02 | 8:00 | 10:00 | No |
Mr A | X | West | 2019-01-03 | 12:00 | 14:00 | Yes |
Mr B | Y | East | 2019-01-03 | 9:00 | 11:00 | No |
Mr C | X | West | 2019-01-03 | 12:00 | 14:00 | Yes |
OK @LearnmesomePBI , this turned out to be WAAAAYYYYY more complex than I anticipated going into it. But I think I have a solution. PBIX is attached.
Column =
VAR __Table =
GROUPBY(
FILTER(
ALL('Table'),
[OT Code] = "X"
),
[Group],
[Date],
"__Min",MINX(CURRENTGROUP(),'Table'[Ot start time]),
"__Max",MAXX(CURRENTGROUP(),'Table'[Ot end time])
)
VAR __Min =
MINX(
FILTER(
__Table,
[Group] = EARLIER([Group]) &&
[Date] = EARLIER('Table'[Date])
),
[__Min]
)
VAR __Max =
MAXX(
FILTER(
__Table,
[Group] = EARLIER([Group]) &&
[Date] = EARLIER('Table'[Date])
),
[__Max]
)
VAR __Table1 =
ADDCOLUMNS(
'Table',
"__Count",
IF([Ot start time] >= __Min || [Ot end time] <= __Max,1,0)
)
VAR __Count =
SUMX(
FILTER(
__Table1,
[Group] = EARLIER([Group]) &&
[Date] = EARLIER([Date])
),
[__Count]
)
RETURN
IF([OT Code] <> "X","No",IF(__Count > 1,"Yes", "No"))
Sorry for my delay in responding. I have a fairly large file and wanted to "kick the tires" on your proposed solution and see if it was working as intended in all circumstances. Good news is that it works amazing.
I did run into a problem whereby some transaction lines spanned two calendar days. Ex. 2019-05-24 OT start at 23:00 and finished 01:15.
I ended up creating a bunch of conditional columns in the query editor and using the unpivot function to break the transaction out on two lines and then your calculation executed appropriately.
Thanks so much Greg for all of your help. Wicked solution!
User | Count |
---|---|
127 | |
108 | |
99 | |
63 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |