Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
10 |
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
8 |