Forum Discussion

PatrickLamoste's avatar
6 years ago
Solved

Sum with ID and Date from a different table

Hi,   I am currently working on 2 tables. The 1st table has the regular hours and the 2nd one has the OT hours.   What I am trying to achieve is to have the OT hours in  a new column in the Regul...
  • v-lili6-msft's avatar
    v-lili6-msft
    6 years ago

    hi, PatrickLamoste 

    For your case, you need to create a new table by this formula:

    Table = 
    SUMMARIZE (
        Table1,
        Table1[Employee ID],
        Table1[Date],
        "Regular Hours", CALCULATE ( SUM ( Table1[Hours] ) ),
        "OT Hours", CALCULATE (
            SUM ( Table2[Hours] ),
            FILTER (
                Table2,
                Table2[Employee ID] = Table1[Employee ID]
                    && Table2[Date] = Table1[Date]
            )
        )
    )

    Result:

     

    and here is sample pbix file, please try it.

     

    Regards,

    Lin