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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Green_Cloud
Helper I
Helper I

Calculating Average while ignoring zero/null values

Hi All,

 

I need to find out average based on the following dataset. But I just need to show the available month's value in the average when one of the month's value is null or zero. The formual I used for average is: 

Two Month's Average = ((CALCULATE(SUM([Working Hour]), FILTER('Sample','Sample'[Month]="February"))) + (CALCULATE(SUM([Working Hour]), FILTER('Sample','Sample'[Month]="March"))))/2

 

Dataset:

Green_Cloud_0-1667569701252.png

 

I have the current output as follows. But it is inaccurate when the filtered value is either 'Alex' or 'John' as they have zero working hours in one of the months. I need a dax which can ignore null/zero values. The desired average value for 'Alex' should be 4 and for 'John', it should be 3. 

 

Green_Cloud_1-1667569731096.png

 

Below is the Power BI file link-

https://drive.google.com/file/d/1vRA6h82VIT7zvvtFczW3eJnr-gxXC-z2/view?usp=share_link

 

Thanks

1 ACCEPTED SOLUTION

Hi,

Thank you for your feedback.

Could you please check the below measure and the attached file, whether it suits your requirement?

 

Average (February & March) = 
(
    (
        CALCULATE (
            SUM ( [Working Hour] ),
            FILTER ( 'Sample', 'Sample'[Month] = "February" )
        )
    )
        + (
            CALCULATE (
                SUM ( [Working Hour] ),
                FILTER ( 'Sample', 'Sample'[Month] = "March" )
            )
        )
)
    / COUNTROWS (
        FILTER (
            'Sample',
            'Sample'[Month]
                IN { "February", "March" }
                && 'Sample'[Working Hour] <> 0
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

7 REPLIES 7
Green_Cloud
Helper I
Helper I

edited

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below.

Please check the attached pbix file.

 

 

Avg measure: = 
CALCULATE (
    AVERAGE ( 'Sample'[Working Hour] ),
    FILTER ( 'Sample', 'Sample'[Working Hour] <> 0 )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim , Thanks so much for your solution! It's close but I needed to make a slight change in the dataset. I needed to filter out the data only for February and March to calculate average. Attached is the link with updated file-

https://drive.google.com/file/d/1vRA6h82VIT7zvvtFczW3eJnr-gxXC-z2/view?usp=share_link

Hi,

Thank you for your feedback.

Could you please check the below measure and the attached file, whether it suits your requirement?

 

Average (February & March) = 
(
    (
        CALCULATE (
            SUM ( [Working Hour] ),
            FILTER ( 'Sample', 'Sample'[Month] = "February" )
        )
    )
        + (
            CALCULATE (
                SUM ( [Working Hour] ),
                FILTER ( 'Sample', 'Sample'[Month] = "March" )
            )
        )
)
    / COUNTROWS (
        FILTER (
            'Sample',
            'Sample'[Month]
                IN { "February", "March" }
                && 'Sample'[Working Hour] <> 0
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks so much @Jihwan_Kim . It worked. I also need to find an average of conversion rate as follows. But the average is not accurate when it comes to the average conversion of of 'David' or 'Maya'. For David, it should be- 108.335 and for Maya-30.555

Green_Cloud_0-1667583025576.png

 

Below is the updated PBI file-
https://drive.google.com/file/d/1MPwUn89yxiUYwSWpJKispl7LesBJQd9Y/view?usp=share_link

 

The Dataset-

Green_Cloud_0-1667579952983.png

 

 

Hi,

Please check the attached file whether it suits your requirement.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

It should ignore the 0% conversion rate for John and Alex. It is considering that. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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