cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
solvisig Regular Visitor
Regular Visitor

Average aggregates discard 0 values

Hi, 

I´m having issue with the aggregated value of average.

the average value is calculated with all the underlying rows taken into account. I want it to discard 0 values.

 

underlying table:

source table

 

my matrix:

I want this to show (2+6+5,5)/3 = 4,5   not 4,2 as this is currently calculating (0+3+4+6+8)/5 = 4,2

 

I want also this to discard the 0 value when I filter these valuse and display total average of 3:

 

any clever DAX suggestions? 🙂

 

Note: I´m not using any measures in this example and I select this option to aggregate:

1 ACCEPTED SOLUTION

Accepted Solutions
Omega Established Member
Established Member

Re: Average aggregates discard 0 values

@solvisig 

 

Try creating the below measure: 

 

Average = AVERAGEX(FILTER(Table1,Table1[Value] <>0),Table1[Value])

 

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Average aggregates discard 0 values

Hi @solvisig

How about adding a slicer on Value to eliminate the zeros? 

solvisig Regular Visitor
Regular Visitor

Re: Average aggregates discard 0 values

That does not work for my scenario as I might have another value in the table that does not have 0 and I want to display.
Example:

3.PNG

Omega Established Member
Established Member

Re: Average aggregates discard 0 values

@solvisig 

 

Try creating the below measure: 

 

Average = AVERAGEX(FILTER(Table1,Table1[Value] <>0),Table1[Value])

 

View solution in original post

Super User
Super User

Re: Average aggregates discard 0 values

@solvisig

Then create a measure. Something simple like:

CALCULATE(AVERAGE(Table[Value]), Table[Value] <>0)

solvisig Regular Visitor
Regular Visitor

Re: Average aggregates discard 0 values

@Omega, Thanks, This is exactly what I was looking for 🙂

 

I already created this DAX... but I had a feeling that there was some function for this:

MyAvg = CALCULATE(SUM(Table1[Value])/COUNTROWS(Table1);FILTER(Table1;Table1[Value] <> 0))

 

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 45 members 964 guests
Please welcome our newest community members: