Forum Discussion

navarrobr's avatar
navarrobr
Frequent Visitor
10 years ago
Solved

Calculate Overtime

I have the following table representing available and worked hours for each employee, in each day: Date Employee Hours Hour Type 01/05/2016  Marcelo 8 available 01/05/2016 Marcelo 9...
  • v-qiuyu-msft's avatar
    10 years ago

    Hi navarrobr,

     

    In your scenario, you can create two new tables 'Woked' and 'Available', then build a relationship between those two tables. Please follow steps below:

     

    1. Create 'Available' table.

     

    Available = SUMMARIZE('Table','Table'[Date],"Available Hours",CALCULATE(SUM('Table'[Hours]),'Table'[Hour Type]="available"))

     

     

     

    2. Create 'Worked' table' and a calculated column 'OverTime'.

     

    Worked = SUMMARIZE('Table','Table'[Date],"Worked Hours",CALCULATE(SUM('Table'[Hours]),'Table'[Hour Type]="worked"))

     

    OverTime = IF('Worked'[Worked Hours]>RELATED('Available'[Available Hours]),[Worked Hours]-RELATED('Available'[Available Hours]),0)

     

     

    3. Build relationships.

     

     

     

    4. Create a table visual.

     

     

    If you have any question, please feel free to ask.

     

    Best Regards,
    Qiuyun Yu