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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
TCatron18
Helper II
Helper II

Multi-Record Calculation Issue

Hello-

I have a calculation for obtaining hours from the past 12 months based on the effective date of an action. I am running into an issue when there are multiple actions that have occurred in the dataset where the first value calculates the correct sum of hours; however, the second value is the sum of all hours regardless of date. What am I missing in my calculation to account for these multiple records to calculate appropriately for each instance? 

Past 12 Months Hours =
VAR _EndDate = SELECTEDVALUE( 'PRN Conversion Data'[Effective Date] )
VAR _StartDate = DATEDIFF( _EndDate, -12, MONTH )
RETURN
CALCULATE(
SUM( 'Past 12 Months Hours'[HOURS] ),
FILTER( 'Past 12 Months Hours',
'Past 12 Months Hours'[PER_BEG_DATE] <= _EndDate
&& 'Past 12 Months Hours'[PER_END_DATE] >= _StartDate
)
)
My example employee has two records:
EE IDEffective Date

Hours

12341/7/2024570.50
123410/26/20253,524.61

The hours for 1/7/2024 is correct. The hours for 10/26/2025 is incorrect and should be 1,431.54, but instead it's totalling all hours the employee has in the hours table. 

Thanks in advance for any assistance!!

1 ACCEPTED SOLUTION

Thank you @GeraldGEmerick  Looks like using EDATE fixed the issue 🙂

View solution in original post

2 REPLIES 2
GeraldGEmerick
Super User
Super User

@TCatron18 You are using DATEDIFF incorrectly here. DATEDIFF calculates the difference between two dates, it does not return an actual date value. But, because a date is technically a number, you aren't getting an error. Try using EOMONTH instead of DATEDIFF to return an actual date.

Thank you @GeraldGEmerick  Looks like using EDATE fixed the issue 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors