Forum Discussion
Sum with ID and Date from a different table
- 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
Hi v-lili6-msft Lin,
Thank you for your reply. I tried to tweak the formula a bit but still a dead end.
I was wondering if it's possible to summarize Table2 [OT] and will be put into Table1 [RegularHours]. But since Table 1 has duplicate dates I need to only display 7 and not the sum of the whole row when I put it in a visual. Like this.
| Table1 | ||||
| Employee ID | Hour Type | Date | Hours | OT Hours Sum |
| 110290 | Regular Hours | 24/04/2019 | 1 | 7 |
| 110290 | Regular Hours | 24/04/2019 | 3 | 7 |
| 110290 | Regular Hours | 24/04/2019 | 2 | 7 |
| Table2 | |||
| Employee ID | Hour Type | Date | Hours |
| 110290 | OT Hours | 24/04/2019 | 2 |
| 110290 | OT Hours | 24/04/2019 | 3 |
| 110290 | OT Hours | 24/04/2019 | 2 |
So when I put in a table visual it would look like this:
| Visual: Table | |||
| Employee ID | Date | Regular Hours | OT Hours |
| 110290 | 24/04/2019 | 6 | 7 |
Hi,
If your end objective is to show Regular and OT hours in a single Table visual, then you need not bring over OT hours from Table2 into Table1. If my approach looks suitable to you, then post back and I will share my solution with you.