1. First, join both the sheets using ID field.
2. Drag and drop the Id field into sheet.
3. Create a calculated field as below
IF Table1.[ID] = Table2.[ID] THEN LAST(logout) - FIRST(login)
4. Now Click Ok.
5. Drop the calculated field into the shelf next to it, log in and logout field to observe the difference.
6. To get the average time for every teacher, calculate the average of the created field for a month.
Hope it helps you.