Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aktripathi2506
Helper IV
Helper IV

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.

1 ACCEPTED SOLUTION
jahida
Impactful Individual
Impactful Individual

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

View solution in original post

18 REPLIES 18
v-haibl-msft
Employee
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

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.

 

hi @aktripathi2506

 

This is the result that you want?

 

Efficiency per Week and TotalEfficiency per Week and Total




Lima - Peru

Hi @Vvelarde,

 

Seems good. Can you please advise how did you do that so I can also try the same and then confirm you if it works for me too.

 

Thanks.

hi @aktripathi2506

 

Measure Efficiency:

 

Efficiency =
AVERAGEX (
    SUMMARIZE (
        'Average-Table';
        'Average-Table'[week];
        "Efficiency"SUM ( 'Average-Table'[hours spent] )
            AVERAGE ( 'Average-Table'[Available hours for the week] )
    );
    [Efficiency]
)

 

Measure%Effic:

 

%Effic = 1-[Efficiency]




Lima - Peru

Have you tried either of the methods we suggested?

Yes I tried your its not giving me the expected result. I thought about creating the new column before as well but it is difficult because: you have to get the sum of hours grouping by week and then divide it by the average of available hours group by week.

 

In a new column i can not do  [hours spent/available hours for each week] for each row because that will give me different value.

What do you have in PowerBI right now? Do you only have one table or have you built out that summary table at all yet? I think both of us assumed you had that summary table built out, which might be incorrect.

In power BI I have the first table in my previous post refered as raw data.

 

That summary table I have given is just for understanding point of view (Excel way). 

 

I want to do all this calculation in power BI, in excel it is easy to do, thats why I gave example by excel that how to achieve the desired result.

Yeah ok my bad for misunderstanding. Did you try the most recent measure?

Hi,

 

What you mean by most recent measure? I tried the one you suggested.

Thanks.

Message 10 in the thread, I've pasted it here:

 

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

jahida
Impactful Individual
Impactful Individual

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

Hi @jahida @Vvelarde,

 

by using this formula I created the measure which calculates the average of 13 weeks i.e. 1 quarter, for different group.

Please find below the table which I got as an output.

 

Group NameMeasure
Sales87.86%
Marketing98.98%
manuf.97.57%
IT99.86%
DB100.00%
SSC98.75%
HR 
Comm94.13%
AB96.48%
DT97.76%
Ramp99.25%
Control99.13%
planning95.08%
Distr.97.64%
  

 

 

This is working fine, Now I am strugling to add one more addition in it..

How can we get the average of these numbers displaying in power bi table/matrix vidual?

 

Average97.11%

 

This is what I want to add.

 

Thanks.

Awesome. This is great.

Very good logic, solved the problem.

Thanks a lot truely.

SamLester
Employee
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)

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.

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.