Forum Discussion

aktripathi2506's avatar
10 years ago
Solved

Calculating average of measures

I have created a measure which calculate the efficiency per week by following formula:

1 - DIVIDE([Hour Spent],[Total available hours])

 

I have calculated week after week this, now I want the average of these values (13 week i.e. quarter 1) as a result.

 

weekgroupHours SpentAverage of CapacityEfficiency
1sales 2141
2sales4.5552.50.991855
3sales107120.985955
4sales10.5659.50.984079
5sales20.57340.972071
6sales25776.750.967815
7sales32622.50.948594
8sales25493.750.949367
9sales4653.250.993877
10sales11.57150.983916
11sales9.51051.250.990963
12sales6.5667.50.990262
13sales21.5627.750.965751
Total 180.5690.97

0.74

 

As we can see at the bottom I am getting .74 , rather than this I am expecting the average of efficiency which should be .9788.

How can we get that value. Please advice and help.

  • Asumming you don't have that summary table built out and you just want to plug the initial table into a matrix or table visual, here's a measure you can use (might be minor syntax errors, I'm not testing but I'm pretty sure the concept is sound):

     

    AVERAGEX(SUMMARIZE(Table, Table[week], "Sum of Hours", SUM(Table[hours spent]), "Average available", AVERAGE(Table[Available hours for the week])), 1 - DIVIDE([Sum of Hours], [Average available]))

18 Replies

  • SamLester's avatar
    SamLester
    Icon for Microsoft Employee rankMicrosoft Employee

    The .74 you are seeing is the calculation of 1 - DIVIDE([Hour Spent],[Total available hours]) (1 - 180.5/690.97) for the totals, not the average of the efficiencies measures. My suggestion would be to remove the Totals line and calculate a new measure that is the average of the efficiencies as opposed to applying the efficiencies formula to the totals, which is what you are currently doing.

     

    Thanks,
    Sam Lester (MSFT)

    • aktripathi2506's avatar
      aktripathi2506
      Icon for Helper IV rankHelper IV

      Hi,

      Thank you for the reply. Yes .74 is becoz of  (1 - 180.5/690.97) . 

      But its not possible to create a measure which is average of another measure, it should be column as average function only accepts a column reference as an argument. Thats why its not working in my case.

       

      • jahida's avatar
        jahida
        Icon for Impactful Individual rankImpactful Individual

        I need a bit more information about the structure of your data to give an exact answer, but in general, the simple work-around to the AVERAGE function requiring a column is to use AVERAGEX(TableName, [Measure]). So something like AVERAGEX(Table, ___) might work, where ___ is either [Efficiency] or the DAX expression used to generate [Efficiency]. 

  • v-haibl-msft's avatar
    v-haibl-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    aktripathi2506,

     

    You can try to use AVERAGEX(TableName, [Measure]) as jahida mentioned. Another method is to change your Efficiency from measure to column, so that you can use the Quick Calc function (Average) in the Table chart.

    If problem still persists, please provide some sample data of your tables so that we can solve it exactly.

     

    Best Regards,

    Herbert

    • aktripathi2506's avatar
      aktripathi2506
      Icon for Helper IV rankHelper IV

      Thank you v-haibl-msftand jahida

       

      Please find below the example of raw data:

       

      weekhours spentAvailable hours for the week
      12200
      14200
      16200
      15200
      16200
      13200
      16200
      18200
      19200
      14200
      22400
      28400
      21400
      25400
      20400
      23400
      37500
      34500
      39500
      33500
      31500
      45100
      43100
      41100
      47100
      53600
      59600
      52600
      56600
      54600

       

      This is the raw data.

      The desired output is as below calculated in excel:

       

           
      WeekSum of Hoursaverage of available hoursefficiency% eff
      1532000.26574%
      2194000.047595%
      3245000.04895%
      4161000.1684%
      5246000.0496%
           
        Final exp. Result0.1189%
           

       

       

      Now I am trying to do the same thing in power BI with the very large data set for 52 weeks.

      Please advise.

       

      • jahida's avatar
        jahida
        Icon for Impactful Individual rankImpactful Individual

        Have you tried either of the methods we suggested?