cancel
Showing results for
Did you mean:
Established Member

## Need help to calculate Average

I am trying to calculate the average of each employees time spend hours.

Sample data:-

 Emp ID begin_date SpendHrs 123 4/2/2018 0:00 8.28 123 4/3/2018 0:00 9.55 123 4/4/2018 0:00 8.19 123 4/5/2018 0:00 8.44 123 4/6/2018 0:00 10.09 123 4/9/2018 0:00 9.58 123 4/10/2018 0:00 9.41 123 4/11/2018 0:00 8.47 123 4/12/2018 0:00 10.38 123 4/13/2018 0:00 10.01 123 4/14/2018 0:00 1.41 123 4/16/2018 0:00 10.01 123 4/17/2018 0:00 9.01

Im using begin date as a slicer to change the date range.

In above image 8.68 is the overall average for that perticular emp id for that perticular date range.

now as date range changes the average also changes.

Now i would like to write a measure or calculated column which will give me the overall average for that percticular date range.

expected output:-

 Emp ID begin_date SpendHrs Avg 123 4/2/2018 0:00 8.28 8.68 123 4/3/2018 0:00 9.55 8.68 123 4/4/2018 0:00 8.19 8.68 123 4/5/2018 0:00 8.44 8.68 123 4/6/2018 0:00 10.09 8.68 123 4/9/2018 0:00 9.58 8.68 123 4/10/2018 0:00 9.41 8.68 123 4/11/2018 0:00 8.47 8.68 123 4/12/2018 0:00 10.38 8.68 123 4/13/2018 0:00 10.01 8.68 123 4/14/2018 0:00 1.41 8.68 123 4/16/2018 0:00 10.01 8.68 123 4/17/2018 0:00 9.01 8.68 Avg = 8.68

How can i get this done.

thanks,

Mohan V

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

## Re: Need help to calculate Average

@MohanV,

Create a measure instead of calculated column.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Highlighted
Super User

## Re: Need help to calculate Average

I’m. It 100% clear what you want, but it sounds like you want this

=calculate(average(table[hours]),All(table[date]))

Or possibly

=calculate(average(table[hours]),Allselected(table[date]))

* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Established Member

## Re: Need help to calculate Average

i tried what you have suggested.

i have written calculated column for the both functions.

below are the outputs that  i have got.

`_Avg = calculate(average('table'[SpendHrs]),ALLSELECTED('table'[begin_date]))`

`_Avgcolumn = calculate(average('Table'[SpendHrs]),ALL('Table'[begin_date]))`

Moderator

## Re: Need help to calculate Average

@MohanV,

Create a measure instead of calculated column.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 328 members 3,347 guests
Recent signins: