Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
TCatron18
Helper I
Helper I

Sum of Column Based on Date of Another Column

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

IDHOURSBEGINEND
174.274/20/20255/3/2025
153.674/6/20254/19/2025
183.413/23/20254/5/2025
175.513/9/20253/22/2025
143.932/23/20253/8/2025
133.982/9/20252/22/2025
169.661/26/20252/8/2025
187.481/12/20251/25/2025
172.6812/29/20241/11/2025
140.8712/15/202412/28/2024
161.4712/1/202412/14/2024
157.1911/17/202411/30/2024
191.911/3/202411/16/2024
187.1210/20/202411/2/2024
166.2510/6/202410/19/2024
196.59/22/202410/5/2024
156.259/8/20249/21/2024

 

Data Table

IDEFFECTIVE
14/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:

IDEFFECTIVEHOURS
14/6/2025

1024.2

 

Any assistance in getting this achieved would be greatly appreciated.

Thanks!!

1 ACCEPTED SOLUTION
Deku
Super User
Super User

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]

)

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

2 REPLIES 2
Deku
Super User
Super User

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]

)

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

@Deku Thank you 😁 That works perfectly!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

Top Solution Authors