The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
My clock in and clock out date is in rows.
Below DAX helped me subtract the break time of 45 minutes from the employees who worked 8hrs or more perday since it's mandatory. However, I wanted to edit it to include another clause where if employee who works 6hrs or less then "Do not deduct break time" but I am unable to make it work. Any suggestions on how I can achieve this with current DAX? Also, if there is better and easier way to achieve the end results please suggest that as well. Thank you!
Solved! Go to Solution.
Hi @jackisc ,
Here are the steps you can follow:
1. In Power Query -- add Column – Index Column – From 1.
2. Create calculated column.
Date_time =
[Date]+[Time]
Test01 =
var _last=
MAXX(
FILTER('Table',
'Table'[Index.1]=EARLIER('Table'[Index.1])-1&&'Table'[In/Out]="In"),[Date_time])
return
DATEDIFF(
_last, [Date_time] , HOUR)
Test02 =
var _result=
IF(
[Test01]=BLANK(),
MAXX(
FILTER(ALL('Table'),'Table'[Index.1]=EARLIER('Table'[Index.1])+1&&'Table'[In/Out]="Out"),[Test01]),[Test01])
return
IF(
_result>=8,"8hr - subtracting 45 minutes of break time","6hr - no need to subtract break time")
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @jackisc ,
Here are the steps you can follow:
1. In Power Query -- add Column – Index Column – From 1.
2. Create calculated column.
Date_time =
[Date]+[Time]
Test01 =
var _last=
MAXX(
FILTER('Table',
'Table'[Index.1]=EARLIER('Table'[Index.1])-1&&'Table'[In/Out]="In"),[Date_time])
return
DATEDIFF(
_last, [Date_time] , HOUR)
Test02 =
var _result=
IF(
[Test01]=BLANK(),
MAXX(
FILTER(ALL('Table'),'Table'[Index.1]=EARLIER('Table'[Index.1])+1&&'Table'[In/Out]="Out"),[Test01]),[Test01])
return
IF(
_result>=8,"8hr - subtracting 45 minutes of break time","6hr - no need to subtract break time")
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
@jackisc Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
Dataset sample
@jackisc Thanks but can you paste that as text so I don't have to type it all?
Date Check in-out time In/Out Time Index End Result
1/3/2024 Checking-in In 07:00:05 1 8hr - subtracting 45 minutes of break time
1/3/2024 Checking-out Out 15:45:00 2
1/4/2024 Checking-in in 09:00:00 1 6hr - no need to subtract break time
1/4/2024 Checking-out out 15:01:00 2
1/5/2024 Checking-in in 07:30:00 1 8hr - subtracting 45 minutes of break time
1/5/2024 Checking-out out 16:15:00 2
User | Count |
---|---|
14 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
28 | |
19 | |
14 | |
8 | |
5 |