Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I am needing to pull the sum of hours for an ID into another table for the date ranges that are within the past 12 months of the effective date.
I've tried several different DAX formulas without any luck.
I have two tables:
Hours Table
ID | HOURS | BEGIN | END |
1 | 74.27 | 4/20/2025 | 5/3/2025 |
1 | 53.67 | 4/6/2025 | 4/19/2025 |
1 | 83.41 | 3/23/2025 | 4/5/2025 |
1 | 75.51 | 3/9/2025 | 3/22/2025 |
1 | 43.93 | 2/23/2025 | 3/8/2025 |
1 | 33.98 | 2/9/2025 | 2/22/2025 |
1 | 69.66 | 1/26/2025 | 2/8/2025 |
1 | 87.48 | 1/12/2025 | 1/25/2025 |
1 | 72.68 | 12/29/2024 | 1/11/2025 |
1 | 40.87 | 12/15/2024 | 12/28/2024 |
1 | 61.47 | 12/1/2024 | 12/14/2024 |
1 | 57.19 | 11/17/2024 | 11/30/2024 |
1 | 91.9 | 11/3/2024 | 11/16/2024 |
1 | 87.12 | 10/20/2024 | 11/2/2024 |
1 | 66.25 | 10/6/2024 | 10/19/2024 |
1 | 96.5 | 9/22/2024 | 10/5/2024 |
1 | 56.25 | 9/8/2024 | 9/21/2024 |
Data Table
ID | EFFECTIVE |
1 | 4/6/2025 |
I am needing to pull the sum of the hours from the Hours table into the Data table for hours that were within the past 12 months from the effective date in the Data table.
My data is much larger than provided in the example where the dates in both tables are different for different IDs.
My expected result:
ID | EFFECTIVE | HOURS |
1 | 4/6/2025 | 1024.2 |
Any assistance in getting this achieved would be greatly appreciated.
Thanks!!
Solved! Go to Solution.
Assuming relationship between id in each table
Measure =
Var endDt = selectedvalue( data[effective date])
Var dartDt = datediff( endDt, -12, month )
Return
Sumx(
Filter(
Hours,
hours[begin] <= endDt &&
Hours[end] >= startDt
),
Hours[hours]
)
Assuming relationship between id in each table
Measure =
Var endDt = selectedvalue( data[effective date])
Var dartDt = datediff( endDt, -12, month )
Return
Sumx(
Filter(
Hours,
hours[begin] <= endDt &&
Hours[end] >= startDt
),
Hours[hours]
)