cancel
Showing results for
Did you mean:
New Member

## How to find the average of a date

We have a business unit that wants us to create a report that aggregates a number of fields, including a couple of milestone dates.  In the excel version of the report that we are basing it from, they just take the average of the dates to show on the aggregate row.  I tried doing the following, but it returns as an Number, which Power BI does not allow you to format as a date:

`AVG SC = AVERAGEA('DBOP Pipeline'[SC])`

If I put "DATEVALUE()" around the number, it throws an error.

1 ACCEPTED SOLUTION
New Member

I figured out how to get around the formatting problem, it's pretty dumb:

`AVG SC = FIRSTDATE('DBOP Pipeline'[SC])+ INT(AVERAGEA('DBOP Pipeline'[SC]) - FIRSTDATE('DBOP Pipeline'[SC]))`

Also, I figured out this method for finding the "middle" date:

`MID SC = FIRSTDATE('DBOP Pipeline'[SC])+ INT( DATEDIFF(FIRSTDATE('DBOP Pipeline'[SC]),LASTDATE('DBOP Pipeline'[SC]),DAY)/2)`

New Member

I figured out how to get around the formatting problem, it's pretty dumb:

`AVG SC = FIRSTDATE('DBOP Pipeline'[SC])+ INT(AVERAGEA('DBOP Pipeline'[SC]) - FIRSTDATE('DBOP Pipeline'[SC]))`

Also, I figured out this method for finding the "middle" date:

`MID SC = FIRSTDATE('DBOP Pipeline'[SC])+ INT( DATEDIFF(FIRSTDATE('DBOP Pipeline'[SC]),LASTDATE('DBOP Pipeline'[SC]),DAY)/2)`

Announcements

#### Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

#### Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors