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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jay2022
Helper IV
Helper IV

How do i ignore zeros when calculating an average in new measure

So I have a formula like so 

 

SUM DAYS = SUM(Data1[Number of weekdays])+SUM(Data2[Number of weekdays]) How do i exclude 0's in this caclulation 

 

To make the following give a more accurate result 

AVG = [SUM WEEKDAYS}/[COUNT OF RECORDS}

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jay2022 ,

I create two tables as you mentioned.

vyilongmsft_0-1726628439248.png

vyilongmsft_1-1726628457547.png

Then I create two measures and here are the DAX codes.

NonullDate1 = 
IF (
    MAX ( 'Table1'[End Date] ) = BLANK (),
    0,
    MAX ( 'Table1'[Number of weekdays] )
)

vyilongmsft_2-1726628609200.png

NonullDate2 =
IF (
    MAX ( 'Table2'[End Date] ) = BLANK (),
    0,
    MAX ( 'Table2'[Number of weekdays] )
)

vyilongmsft_3-1726628637741.png

Next you can create a new measure.

Measure = SUMX('Table1','Table1'[NonullDate1]) + SUMX('Table2','Table2'[NonullDate2])

vyilongmsft_4-1726628704628.png

 

 

Best Regards

Yilong Zhou

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

3 REPLIES 3
Jay2022
Helper IV
Helper IV

Thank you I think the problem is i'm actually counting the records based on an id but some of the weekdays that are being counted are 0 due to an end date column (of the spreadsheet) not yet being input. It's a tricky one.

Anonymous
Not applicable

Hi @Jay2022 ,

I create two tables as you mentioned.

vyilongmsft_0-1726628439248.png

vyilongmsft_1-1726628457547.png

Then I create two measures and here are the DAX codes.

NonullDate1 = 
IF (
    MAX ( 'Table1'[End Date] ) = BLANK (),
    0,
    MAX ( 'Table1'[Number of weekdays] )
)

vyilongmsft_2-1726628609200.png

NonullDate2 =
IF (
    MAX ( 'Table2'[End Date] ) = BLANK (),
    0,
    MAX ( 'Table2'[Number of weekdays] )
)

vyilongmsft_3-1726628637741.png

Next you can create a new measure.

Measure = SUMX('Table1','Table1'[NonullDate1]) + SUMX('Table2','Table2'[NonullDate2])

vyilongmsft_4-1726628704628.png

 

 

Best Regards

Yilong Zhou

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

Greg_Deckler
Community Champion
Community Champion

@Jay2022 Well, if you are summing, then you are ignoring 0's. The problem then I assume is with your count of records measure which should be something like:

COUNT OF RECORDS = 
  COUNTROWS( FILTER( 'Data1', [Number of weekdays] <> 0 ) ) + COUNTROWS( FILTER( 'Data2', [Number of weekdays] <> 0 ) )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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