Reply
Established Member
Posts: 287
Registered: ‎02-14-2017
Accepted Solution

Need help to calculate Average

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

Sample data:-

 

Emp IDbegin_dateSpendHrs
1234/2/2018 0:008.28
1234/3/2018 0:009.55
1234/4/2018 0:008.19
1234/5/2018 0:008.44
1234/6/2018 0:0010.09
1234/9/2018 0:009.58
1234/10/2018 0:009.41
1234/11/2018 0:008.47
1234/12/2018 0:0010.38
1234/13/2018 0:0010.01
1234/14/2018 0:001.41
1234/16/2018 0:0010.01
1234/17/2018 0:009.01

 

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

Capture.JPG

 

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 IDbegin_dateSpendHrsAvg
1234/2/2018 0:008.288.68
1234/3/2018 0:009.558.68
1234/4/2018 0:008.198.68
1234/5/2018 0:008.448.68
1234/6/2018 0:0010.098.68
1234/9/2018 0:009.588.68
1234/10/2018 0:009.418.68
1234/11/2018 0:008.478.68
1234/12/2018 0:0010.388.68
1234/13/2018 0:0010.018.68
1234/14/2018 0:001.418.68
1234/16/2018 0:0010.018.68
1234/17/2018 0:009.018.68
  Avg = 8.68

 

How can i get this done.

 

Please help me.

 

thanks,

Mohan V


Accepted Solutions
Highlighted
Moderator
Posts: 9,944
Registered: ‎03-10-2016

Re: Need help to calculate Average

@MohanV,

Create a measure instead of calculated column.

1.PNG

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.

View solution in original post


All Replies
Super User
Posts: 1,627
Registered: ‎07-03-2015

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
Posts: 287
Registered: ‎02-14-2017

Re: Need help to calculate Average

@MattAllington thanks for the reply

 

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]))

Capture.JPG

 

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

 Page1.JPG

 

Please help me.

Highlighted
Moderator
Posts: 9,944
Registered: ‎03-10-2016

Re: Need help to calculate Average

@MohanV,

Create a measure instead of calculated column.

1.PNG

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.