Forum Discussion
christianfcbmx
Post Patron
8 years agoNeed help with my formula
I have a power BI formula which I have in excel working correctly but in PBI is not getting right results: what this formula needs to do is to count working hours between 2 dates with 2 restrictions ...
- 8 years ago
Try this Calculated Column
Calculated Column = VAR MyStartDate = IF ( HOUR ( TableName[Start] ) < 8, INT ( TableName[Start] ) + 8 / 24, TableName[Start] ) VAR MyEndDate = IF ( HOUR ( TableName[End] ) > 18, INT ( TableName[End] ) + 18 / 24, TableName[End] ) VAR MyDates = ADDCOLUMNS ( GENERATESERIES ( MyStartDate, MyEndDate ), "Day", WEEKDAY ( [Value], 2 ) ) VAR StartTime = IF ( HOUR ( MyStartDate ) <= 18, HOUR ( MyStartDate ) + MINUTE ( MyStartDate ) / 60 - 8 ) VAR EndTime = IF ( HOUR ( MyEndDate ) > 8, HOUR ( MyEndDate ) + MINUTE ( MyEndDate ) / 60 - 8, 10 ) VAR Result = 10 * ( COUNTROWS ( FILTER ( mydates, [Day] <= 5 ) ) - 1 ) - StartTime + EndTime RETURN IF ( EndTime < StartTime, Result + 10, Result )
Zubair_Muhammad
Community Champion
8 years agoZubair_Muhammad
Community Champion
8 years ago