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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
swebb
Helper II
Helper II

Issue with DATEDIFF

All,

 

PBI newbie here. Maybe I'm missing something, not real sure, but I have a measure that I'm using to calculate the average age of an opportunity from our CRM data. It works when coupled with opportunities that have both a createdon date and an actualclosedate; these are both columns in my table. I created another column with the Today() function as the value. What I'm trying to accomplish is show the average age based on the dates(createdon vs today's date, or createdon vs actualclose date) of each opportunity. Thoughts?

 

Current working formula: 

Avg Age = AVERAGEX (opportunity, DATEDIFF ( [createdon], [actualclosedate], DAY)

Tried:

Opp Avg Age = AVERAGEX (opportunity, DATEDIFF ([created on], [today], DAY) >>> The result I get is ever single column added up and averaged (so instead of individual number of days per opportunity, it's just entire column added and averaged)

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @swebb 

please try

Avg Age =
AVERAGEX (
opportunity,
DATEDIFF ( [createdon], COALESCE ( [actualclosedate], TODAY () ), DAY )
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @swebb 

please try

Avg Age =
AVERAGEX (
opportunity,
DATEDIFF ( [createdon], COALESCE ( [actualclosedate], TODAY () ), DAY )
)

Actually, I think we can mark this resolved. I was looking through the records and have determined the counts are accurate. Thank you!

A bit closer, maybe. Still getting some really odd numbers, in to the thousands. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.