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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Average of measures with filters

Hi, I have another issue with measures and averages that I'm trying to solve as follows:

 

Table 1 has the name of stores, departments and sales by department.

 

Table 2 has the name of stores, departments and how many people work in each department,

 

I'm trying to calculate the average of the sales by department.

 

I've got measures as follows: 

Total £ = SUM(Table1[Sales])

Total staff = SUM (Table2[people])

£ per staff = DIVIDE([Total£],[Total staff])

 

I've also got two additional tables for the store and departments created using:

Departments = VALUES('Table 1'[Departments])

Stores= VALUES('Table 1'[Stores])

which are linked to both Table 1 and Table 2.

 

 

I've then got a matrix which shows

 

Store (from Stores Table)     Total £    Total Staff    Total £ per staff

A                                              547            243              2.25

B                                               65              30                2.17

 

I then want to apply a department via a filter (pulled from the Departments table) and calculate the average "total £ per staff" for all of the stores with that department. I've currently got:

 

Average £ per staff = AVERAGEX(Table 1,[£perstaff])

 

(which for the above example would be 2.21) but something is going wrong and the average is too low, it seems to be pulling in everything rather than just what has been filtered (note this is a simplified version and I have a couple of other filters to select the store in the first place - e.g. region/country which might be confusing it too?). 

 

Does anyone have any suggestions?  

 

 

 

4 REPLIES 4
brendanbannon
Frequent Visitor

Hi mate, I had the same question which landed me here. 

 

I've been using the CALCULATE function in my measures and it's a huge help with filtering.  

 

In my scenario, it just solved my problem with filtering the AVERAGE calculation.

 

Hello world! 🙂 Here's what worked for me:

 

[MEASURE_NAME] =
CALCULATE(
     AVERAGE(
             'TABLE1' [ COLUMN ] ) ,
     'TABLE1' [ COLUMN ] [ EXPRESSION]
 
 or in my case (with table1 as a substitute in this example)

 

AVERAGE_MINUTES =
CALCULATE(
     AVERAGE(
             'TABLE1' [MINUTES] ) ,
     'TABLE1' [MINUTES] <= 90 )
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

Try to add SUMMARIZE Function to the formula accordingly.

http://community.powerbi.com/t5/Desktop/Change-table-visualization-total/td-p/322253

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you! that works for the Average using:

 

Average £ per staff = AVERAGEX(SUMMARIZE(Store,Store[Storename]),[£perstaff])

 

I've tried to do similar for a percentile using:

 

Q3 £perFTE = PERCENTILEX.INC(SUMMARIZE(Store,Store[Storename]),[£perstaff],0.25)

 

but it isn't working. the measure is blank. Any ideas on why this works for Average but not Percentile?

Anonymous
Not applicable

Is anyone able to help? Even if it impossible it would be good to know as I can stop trying to make it work. Thanks in advance!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.