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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
gdelvecchio
Regular Visitor

Can't filter a table before calculating Average

Average Account Life 2:=

 

AVERAGEX (

  FILTER (

    'Facts', [Close Date] > [Open Date]),

      DATEDIFF([Open Date], [Close Date], MONTH))

 

The measure above gives me an error saying the DATEDIFF function requires the start date cannot be greater than the end date.  So my Filter isn't working the way I think it should.  Please, someone, tell me what I'm missing.

 

Thanks,

Gabe

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @gdelvecchio,

 

One sample for your refernce. Using the fomula as below, everything worked well.

 

Measure = AVERAGEX(FILTER(Facts,Facts[Open Date]<Facts[Close Date]),DATEDIFF(Facts[Open Date],Facts[Close Date],MONTH))

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Try to work with following formula 

Measure = AVERAGEX(FILTER(Facts, 
Facts[Open Date] < Facts[Close Date]), 
DATEDIFF(Facts[Open Date], 
Facts[Close Date], MONTH))

Hop it will give correct answer.

v-frfei-msft
Community Support
Community Support

Hi @gdelvecchio,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.


Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
v-frfei-msft
Community Support
Community Support

Hi @gdelvecchio,

 

One sample for your refernce. Using the fomula as below, everything worked well.

 

Measure = AVERAGEX(FILTER(Facts,Facts[Open Date]<Facts[Close Date]),DATEDIFF(Facts[Open Date],Facts[Close Date],MONTH))

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.