Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mayassi
Frequent Visitor

Calculate % of hours worked base two different working schedual using a calculated table/measure

Hello Power BI community, I will need some help for this task.

I have two working schedule, the first one include working on saturday for 8 hours whereas the second one only works for 5 hours on that day. I created a calculated column to have a full calendar (removing the sundays) and specify the number of hours per day : 

Mayassi_0-1684189355699.png

The total number of hours worked and the names are on a non calculated table.

The objective is to calculate depending on the person the % of hours worked (filtred by the number of days)

Mayassi_2-1684189646440.png

In short : I want to devide "number of hours worked" by "sum work hour normal/exception" depending on the person.
Thank you for your time and help! 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Mayassi , You already have that part of your table

divide(Sum(Table[Work Hour Normal]), Sum(Table[Work Hour exception]) )

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Thank you, but this does not help me sadly ; i created a new pbix document to share in hope of help (but it seems I can't share it here).
here are examples of all table used :

ID_RRR_date 
1work101/05/2023
2work201/05/2023
3work302/05/2023
4work406/05/2023
5work506/05/2023
6work608/05/2023
ID_R_personID_Rpersontime taken (h)
11A3,00
21B3,00
32C2,00
42A3,00
54B4,00
65C3,00
75D3,00
86D4,00
96B4,00


What i need to do :

personhours spent on taskwhat i want 
A6,000,11
B11,000,20
C5,000,09
D7,000,13207547

here are the calculate column used and they DAX function :

-Calendar = CALENDAR("01/12/2022","31/12/2023")
-IsWeekday = WEEKDAY(Calendrier[Date],2) <= 6
(!) this is the one used for the filter :
-Date without sunday =
var CalendarYearMonth = Calendrier[Date]
var LoadedAtYearMonth = Calendrier[IsWeekday]=true
return
    if ( Calendrier[IsWeekday]= true,
       
        CalendarYearMonth
    )
-work hours exception = IF(WEEKDAY(Calendrier[Date],2)=6,5, IF(WEEKDAY(Calendrier[Date],2) =7,0,8))
-work hour normal = IF(WEEKDAY(Calendrier[Date],2)<=6,8,0)
these will give the total of hours worked depending on the date filter.
Mayassi_0-1684225623745.png

A,B and C needs to be divided by 56 whereas D  needs to be divided by 53. In my case I only have two people that are exception to the rule, that i can identify with their name.

I am sorry I can't share the pbix document but I did my best to help you help me, in hope of having a solution to this issue, thank you again! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors