cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Responsive Resident

## Average of difference between columns with filters

Hi,

I have a table as on the picture and need to calculate the average difference between the start date and the end date, by supplier excluding rows with a start date after the end date and excluding rows whose start date/end date is"31/12/1899".
I tried the dax below, but it gives me incorrect results, how can I correct it?

TestAverage =
CALCULATE(AVERAGEX('Sheet1',
DATEDIFF('Sheet1'[StartDate],Sheet1[EndDate],DAY)),
FILTER(Sheet1,Sheet1[StartDate]<Sheet1[EndDate] && Sheet1[StartDate]<>31/12/1989 && Sheet1[EndDate]<>31/12/1989))
1 ACCEPTED SOLUTION
Super User

Hi,

``````TestAverage =
AVERAGEX (
FILTER (
Sheet1,
Sheet1[StartDate] < Sheet1[EndDate]
&& NOT ( Sheet1[StartDate] = DATE ( 1899, 12, 31 ) )
&& NOT ( Sheet1[EndDate] = DATE ( 1899, 12, 31 ) )
),
DATEDIFF ( 'Sheet1'[StartDate], Sheet1[EndDate], DAY )
)
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

2 REPLIES 2
Responsive Resident

It worked !! Thank you!

Super User

Hi,

``````TestAverage =
AVERAGEX (
FILTER (
Sheet1,
Sheet1[StartDate] < Sheet1[EndDate]
&& NOT ( Sheet1[StartDate] = DATE ( 1899, 12, 31 ) )
&& NOT ( Sheet1[EndDate] = DATE ( 1899, 12, 31 ) )
),
DATEDIFF ( 'Sheet1'[StartDate], Sheet1[EndDate], DAY )
)
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors