cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rsbin
Post Partisan
Post Partisan

Summarizing data from two tables

Good Afternoon,

 

This should be a fairly straightforward calculation, but I am unable to get the syntax correct.

I would like to combine punch clock data from two different tables into one Summary Table.  I have the first part working correctly which sums Total Hours worked by Employee for each date:

DailySummary = Summarize( OTStatistics, [Date], [Facility], [Employee_Code], [Employee_Name], "TotalHours", SUM( OTStatistics[Hours] ))

 My next step is to create a Calculated Column for the "Scheduled Hours" from a separate table for each row of [Date] and [Employee_Code].  I have tried a number of different ways, but just can't get the Sum for each Row Context correct.  

Pretty sure I will cringe when I see the answer.....

 

As always, your help is very much appreciated.

 

Kindest Regards to All,

 

1 ACCEPTED SOLUTION

Hi @rsbin ,

 

Are you trying add sum scheduled hours in Daily Summary table by date and  Employee? Please try the following calculated column:

 

 

Column =
VAR a = 'Daily Summary'[Date]
VAR b = 'Daily Summary'[Employee_Code]
RETURN
    CALCULATE (
        SUM ( 'Schedule'[FacilityScheduledHours] ),
        TREATAS ( ROW ( "Date", a ), 'Schedule'[Date] ),
        TREATAS ( ROW ( "Employee_Code", b ), 'Schedule'[EEcode] )
    )

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

4 REPLIES 4
TomMartens
Super User II
Super User II

Hey @rsbin ,

 

please create a pbix that contains sample data but still reflects your data model. Upload the pbix to onedrive or dropbox and share the link. If you are using Excel to create the sample data, upload the Excel as well.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens  Hi Tom,

 

Daily Summary Table:

 

DateFacilityEmployee_CodeEmployee NameTotal Hours
6/1/2018Site 1AA01Doe, John12

 

Schedule:

EECodeLastNameFirstNameDateFacilityScheduledHours
AA01DoeJohn6/1/2018Site 18

 

For this date and this Employee, I would like to join the Scheduled Hours into the Daily Summary table.   I hope this clarifies. 

( I still need to learn how to correctly upload a sample pbix) .

Hi @rsbin ,

 

Are you trying add sum scheduled hours in Daily Summary table by date and  Employee? Please try the following calculated column:

 

 

Column =
VAR a = 'Daily Summary'[Date]
VAR b = 'Daily Summary'[Employee_Code]
RETURN
    CALCULATE (
        SUM ( 'Schedule'[FacilityScheduledHours] ),
        TREATAS ( ROW ( "Date", a ), 'Schedule'[Date] ),
        TREATAS ( ROW ( "Employee_Code", b ), 'Schedule'[EEcode] )
    )

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

Hello @v-deddai1-msft 

Thank you for the response.  I have done a quick test and looks like this was the solution I was looking for.

 

I have never used the TREATAS function before....will have to study this in more detail.

 

Thanks again and best regards,

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors