find the 1st break, 2nd break, and lunch from each date and each employee

uwmarkyo

New Member
Joined
Aug 11, 2021
Messages
43
Office Version
  1. 365
Platform
  1. Windows
hi I have a table as below:
I would like to create a column and find 1st break, 2nd break, and lunch.
1691008235603.png


if an agent on the same day, the aux name is Break and Duration is larger than 600. the first break will be the Break1, the second break will be the Break2.
if an agent on the same day, the aux name is Lunch and Duration is larger than 1000, it will be Lunch.

How do I perform this in Power BI DAX? I try couple time but it didn't work.
first Break =
VAR EmployeeDateBreaks =
FILTER(
'Adherence and Deviation',
[Employee Name] = EARLIER([Employee Name]) &&
[Date] = EARLIER([Date]) &&
[Aux Name] = "Break" &&
[Duration] > 600
)
RETURN
IF(
COUNTROWS(EmployeeDateBreaks) > 0 &&
RANKX(EmployeeDateBreaks, [Aux Start], , ASC) = 1,
"Break1",
BLANK()
)
Test.B1.ACTUAL =
VAR CurrentDate = 'Adherence and Deviation'[Date]
VAR CurrentEmployee = 'Adherence and Deviation'[Employee Name]
VAR FilteredTable = FILTER('Adherence and Deviation',[Date] = CurrentDate && [Employee Name] = CurrentEmployee &&
[Aux Name] = "break" &&
[Duration] >= 600)
VAR SecondBreakRow = ADDCOLUMNS ( FilteredTable, "Rank",
RANKX(FILTER('Adherence and Deviation', [Date] = CurrentDate &&
[Employee Name] = CurrentEmployee &&
[Aux Name] = "break" &&
[Duration] >= 600), [Aux Start], , ASC, Dense) )
RETURN IF ( NOT ISEMPTY(FilteredTable), MINX(FILTER(SecondBreakRow, [Rank] = 1), [Aux Start]), BLANK() )

Here is my dataset in table:
Table

thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,088
Messages
6,123,056
Members
449,091
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top