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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Average excluding zero's

How would I write a formula that gives me the average sales but excludes any instances when the sales are zero.

1 ACCEPTED SOLUTION
KHorseman
Community Champion
Community Champion

Assuming this is a simple average of rows of sale data, and not an average of another measure that aggregates sales in some other way...

 

Avg Sales= CALCULATE( AVERAGE(TableName[SaleAmount]), FILTER(TableName, TableName[SaleAmount] <> 0 ))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
Pr136
Regular Visitor

 If we use FILTER in the Formula, it could filter out the dimensions which has values as 0. If we want to show all the dimensions but the average to be calculated based on only the non-zero values, then use something like this. 

AVG-Excluding zero =CALCULATE(AVERAGEX(Mock_Data_For_Paginated_Report_Demo,Mock_Data_For_Paginated_Report_Demo[Overall Rating - Int]),FILTER(ALL(Mock_Data_For_Paginated_Report_Demo),Mock_Data_For_Paginated_Report_Demo[Overall Rating - Int]=Max(Mock_Data_For_Paginated_Report_Demo[Overall Rating - Int])))
hamzashafiq
Kudo Collector
Kudo Collector

Hey,

 

I have similar issue, I want to calculate the "cost/hour" excluding zeros with just dividing "total_cost" with "Average usage by unit" where "Average usage by unit" is a measure. 

 

modelunitAverage Usage by Unittotal_costcost/hour
m1s1 $157.34$0.00
m1s2 $1,603.29$0.00
m1s3 $35.99$0.00
m1s4 $589.13$0.00
m1s5 $719.70$0.00
m1s620$2,657.60$132.88
     
Total 20$2,657.60$132.88
KHorseman
Community Champion
Community Champion

Assuming this is a simple average of rows of sale data, and not an average of another measure that aggregates sales in some other way...

 

Avg Sales= CALCULATE( AVERAGE(TableName[SaleAmount]), FILTER(TableName, TableName[SaleAmount] <> 0 ))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @KHorseman,
I am looking for something very similar, but I want the average of the "Ratio_Measure" excluding the highest and lowest number. Do you think you can help me?

Here is a sample of my data on excel as well as the Power BI dashboard with my measures
Here!! 

Thanks, just needed this code

Good solution. I'm so grateful! Thank you very much!

Anonymous
Not applicable

Perfect...thx!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.