cancel
Showing results for
Did you mean:
Highlighted
Anonymous
Not applicable

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

@Anonymous,

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

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.
Anonymous
Not applicable

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

@Anonymous,

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

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!