The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Ok,
I must calculate the hours worked on an employee's second leave day.
I cannot figure out how to work out whether or not the previous day was a day of leave. I think I am missing something simple.
Here is my logic and my attempts to solve this problem:
1)Did the employee work today? (I have covered this) - Power Query - Total Hours Worked
2) Is today a day of leave? (I have covered this) - Dax calculated Column = =IF([Day Name]="Sunday" || [Day Name]="Saturday" || [STATS]="STAT",1,0)
3) Did the employee work the previous day? (I have covered this) DAX Measure =CALCULATE(DISTINCTCOUNT(TIMESHEETS_2023[START - Date]), PREVIOUSDAY('Calendar'[Date]))
4) Is the previous day a day of leave (Saturday, Sunday or STAT)? (not sure how to address this) this is my attempt DAX Measure =CALCULATE(SUM(TIMESHEETS_2023[DayOffHours]),DATEADD('Calendar'[Date],-1,DAY)) (DAY OFF HOURS = Calculated Column = IF([DayOff]>0,[TotalHoursWorked],0)
5) if all items 1 to 5 are yes, sum the total hours worked today. (not sure how to address this)
If you think you can do this more simply (I am overthinking things) and/or you have ideas to address this calculation, I am very open to learning more and hearing suggestions.
Thank you
Tammy
Solved! Go to Solution.
Hi @tj7933 ,
Please have a try.
PreviousDayOffHours =
CALCULATE(
SUM(TIMESHEETS_2023[DayOffHours]),
DATEADD('Calendar'[Date], -1, DAY)
)
SecondLeaveDayHours =
IF(
[IsLeaveDay] = 1 && [PreviousDayIsLeaveDay] = 1,
[TotalHoursWorked],
BLANK()
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @tj7933 ,
Please have a try.
PreviousDayOffHours =
CALCULATE(
SUM(TIMESHEETS_2023[DayOffHours]),
DATEADD('Calendar'[Date], -1, DAY)
)
SecondLeaveDayHours =
IF(
[IsLeaveDay] = 1 && [PreviousDayIsLeaveDay] = 1,
[TotalHoursWorked],
BLANK()
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |