Forum Discussion
Plz help with Dax
- Anonymous2 years ago
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
- Greg_Deckler2 years ago
Community Champion
jackisc Thanks but can you paste that as text so I don't have to type it all?
- jackisc2 years agoNew Member
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