Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Timesheet Comparison

Hi,

 

I have datasets similar to the below.

 

Dataset 1 - Timesheet Booking Data

DateHours
01/02/202211
02/02/202242
03/02/202253
04/02/202232
05/02/202214
06/02/202266
07/02/202255
08/02/202277

 

Dataset 2 - Timesheet Weekly Summary

Week Ending DateHours Summary
03/02/2022140
10/02/2022220

 

Dataset 3 - Date Table

DateWeek Ending Date
01/02/202203/02/2022
02/02/202203/02/2022
03/02/202210/02/2022
04/02/202210/02/2022
05/02/202210/02/2022
06/02/202210/02/2022
07/02/202210/02/2022
08/02/202210/02/2022

 

I am trying to compare dataset 1 & 2 to make sure the hours booked during the week match the hours summary dataset. 

 

Work weeks run from Friday - Thursday. The date table includes all dates and their corrisponding week ending date. 

 

Dataset 2 - Timesheet Weekly Summary shows a summary of all hours booked during that week corrisponding to a week ending date.

 

DAX Measured needed

 

1. SUM of of all hours per working week in dataset 1 

 

Hope this makes sense.

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

    Here are the steps you can follow:

    1. Create calculated column.

    Week = WEEKDAY('Timesheet Booking Data'[Date])
    Flag =
    RELATED('Timesheet Weekly Summary'[Week Ending Date])
    Flag2 =
    var  _1=RELATED('Timesheet Weekly Summary'[Week Ending Date])
    return
    IF(
    'Timesheet Booking Data'[Date] <='Timesheet Booking Data'[Flag],'Timesheet Booking Data'[Flag],MAX('Timesheet Booking Data'[Flag]))
    Date1 =
    IF(
        'Timesheet Booking Data'[Date]<='Timesheet Booking Data'[Flag2],'Timesheet Booking Data'[Flag2],MAX('Timesheet Weekly Summary'[Week Ending Date]))

    all hours per working week =
    CALCULATE(SUM('Timesheet Booking Data'[Hours]),
    FILTER(ALL('Timesheet Booking Data'),
    'Timesheet Booking Data'[Date1]=EARLIER('Timesheet Weekly Summary'[Week Ending Date])&&'Timesheet Booking Data'[Week] in {4,5}))

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    Here are the steps you can follow:

    1. Create calculated column.

    Week = WEEKDAY('Timesheet Booking Data'[Date])
    Flag =
    RELATED('Timesheet Weekly Summary'[Week Ending Date])
    Flag2 =
    var  _1=RELATED('Timesheet Weekly Summary'[Week Ending Date])
    return
    IF(
    'Timesheet Booking Data'[Date] <='Timesheet Booking Data'[Flag],'Timesheet Booking Data'[Flag],MAX('Timesheet Booking Data'[Flag]))
    Date1 =
    IF(
        'Timesheet Booking Data'[Date]<='Timesheet Booking Data'[Flag2],'Timesheet Booking Data'[Flag2],MAX('Timesheet Weekly Summary'[Week Ending Date]))

    all hours per working week =
    CALCULATE(SUM('Timesheet Booking Data'[Hours]),
    FILTER(ALL('Timesheet Booking Data'),
    'Timesheet Booking Data'[Date1]=EARLIER('Timesheet Weekly Summary'[Week Ending Date])&&'Timesheet Booking Data'[Week] in {4,5}))

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      I have just implemented the above in my dataset with the following changes being made

       

      1. Week ending date is a friday 

      2. Date settings is English - United Kingdom

      3. Extended data 

       

      The Date 1 calculated column is no longer working as intended. Any ideas where I have gone wrong?

       

      Screenshot below for reference.