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
mnb_dk
Helper I
Helper I

Exclude values in Average calculation

Hi there

 

I have a matrix showing product sales and I would like to see the average unit cost for each product. The problem is that the average is incorrect since it includes lines where QTY = blank/0 and includes these in the average calculation. 

 

I can filter on the QTY visual to "Show items when the value is not blank". However it only works if I include the "Size" data point in the matrix and I would like not to show this, so I only have two levels in the matrix:


1. Product ID

2. Color

3. Size (I DONT WANT TO SEE THIS IN MY MATRIX)

 

I would expect to see two colors with an average of 138,36 each and also in total. 

 

Below data example:

ProductColorSizeUnit costsQTY
Product 1BlackL/XL138,3646
Product 1BlackM/L138,3688
Product 1BlackS/M138,36104
Product 1BlackXS/S138,3666
Product 1GreenL129,72 
Product 1GreenL/XL138,3671
Product 1GreenM129,72 
Product 1GreenM/L138,36179
Product 1GreenS129,72 
Product 1GreenS/M138,36216
Product 1GreenXL129,72 
Product 1GreenXS129,72 
Product 1GreenXS/S138,36142
Product 1GreenXXL129,72 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @mnb_dk ,

 

Thanks for the reply from @HotChilli , please allow me to provide another insight: 

Here are the steps you can follow:

1. Create measure.

Measure =
AVERAGEX(
    FILTER(ALL('Table'),
    'Table'[Color]=MAX('Table'[Color])&&[QTY]<>BLANK()),[Unit costs])

2. Result:

vyangliumsft_0-1712825431456.png

 

Best Regards,

Liu Yang

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

8 REPLIES 8
v-yangliu-msft
Community Support
Community Support

Hi  @mnb_dk ,

 

Thanks for the reply from @HotChilli , please allow me to provide another insight: 

Here are the steps you can follow:

1. Create measure.

Measure =
AVERAGEX(
    FILTER(ALL('Table'),
    'Table'[Color]=MAX('Table'[Color])&&[QTY]<>BLANK()),[Unit costs])

2. Result:

vyangliumsft_0-1712825431456.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

HotChilli
Super User
Super User

Put it on 3rd party site (dropbox or similar) and post the link here

HotChilli
Super User
Super User

It will be sufficient.  If you use it in a pbix and post it, I'll see why my suggestions are not working for you.

Ok I will try. But for some reason I can't upload files here?

HotChilli
Super User
Super User

You want to include qty > 0 , not exclude them.  Post your pbix and I'll have a look at it

My pbix contains sensitive data, but the example data provided above should be sufficient?

HotChilli
Super User
Super User

You have a few alternatives:

1. Write your own average measure excluding the rows where qty is empty/0

or

2. Put a visual filter on the matrix to filter in the the qty values you want , for example, include only qty > 0

Using the visual filter by excluding qty values >0 makes no different. Only if I keep the "Size" in the visual. If I remove it, it makes no difference.

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.