Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
hi I have a table as below:
I would like to create a column and find 1st break, 2nd break, and 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() )
thanks
Solved! Go to Solution.
Hi @cyy0296 ,
You were somewhat close. Please, try this code for your calculated column:
Column =
VAR employee = Table_[Employee Name]
VAR day = Table_[Date]
VAR aux = Table_[Aux Name]
VAR duration = Table_[Duration]
VAR rnk =
RANKX (
FILTER (
Table_,
Table_[Employee Name] = employee
&& Table_[Duration] > 600
&& Table_[Date] = day
&& Table_[Aux Name] = "Break"
),
Table_[Aux Start],
,
ASC
)
RETURN
SWITCH (
TRUE (),
aux = "Lunch" && duration > 1000, "Lunch",
aux = "Break" && Table_[Duration] > 600, CONCATENATE ( "Break ", rnk ),
BLANK ()
)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Hi @cyy0296 ,
You were somewhat close. Please, try this code for your calculated column:
Column =
VAR employee = Table_[Employee Name]
VAR day = Table_[Date]
VAR aux = Table_[Aux Name]
VAR duration = Table_[Duration]
VAR rnk =
RANKX (
FILTER (
Table_,
Table_[Employee Name] = employee
&& Table_[Duration] > 600
&& Table_[Date] = day
&& Table_[Aux Name] = "Break"
),
Table_[Aux Start],
,
ASC
)
RETURN
SWITCH (
TRUE (),
aux = "Lunch" && duration > 1000, "Lunch",
aux = "Break" && Table_[Duration] > 600, CONCATENATE ( "Break ", rnk ),
BLANK ()
)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!