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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
BigTommy
Helper I
Helper I

Average witout ZERO

Hi Guys, 

 

I have troulbe with calculating average execluting ZEROS. I have the below code which calculating me the average but is including ZEROS. Where to add <>0 in the below to exclude ZEROS please?

 

 

 

_Landed Ave Product Unit Cost 2019 ALL() =

CALCULATE ( AVERAGEX ( VALUES ( 'Transaction History2019 2020'[Item Number] ), [_Average Landed Unit Cost 2019] ),

ALL ( 'Calendar'[Date] ),

ALL ( 'Transaction History2019 2020'[Number] ), 'Calendar'[Year] = "2019" )

 

 

in case this is important the [_Average Landed Unit Cost 2019] is a measure. See below:

 

_Average Landed Unit Cost 2019 =
CALCULATE (AVERAGE ( 'Transaction History2019 2020'[Landed Unit Cost] ),
ALL ( 'Transaction History2019 2020'[Number] ))
 
the [Landed Unit Cost] is the table where I have values and zeros
 
 
 

zeros.JPG

 

So PBI is calculating 0.467+0.442048835+0.442+0.442 = 1.793048835 / 20 =0.08965

 

and the average should be 1.793048835/4=0.44826220875 

 

 

PLEASE HELP!

 

Thnaks!

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

This is the corrected measure. Always format the DAX. Makes it easy to see where parenthesis are missing @BigTommy 

 

Measure =
CALCULATE(
    AVERAGEX(
        FILTER(
            VALUES( 'Transaction History2019 2020'[Item Number] ),
            [_Average Landed Unit Cost 2019] > 0
        ),
        [_Average Landed Unit Cost 2019]
    ),
    ALL( 'Calendar'[Date] ),
    ALL( 'Transaction History2019 2020'[Number] ),
    'Calendar'[Year] = "2019"
)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @BigTommy ,

 

Try the solution from @edhans .

If the problem persists,could you share a PBIX file with dummy data? 

Please mask any sensitive data before uploading.

 

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

amitchandak
Super User
Super User

@BigTommy , Try

CALCULATE ( AVERAGEX ( filter(VALUES ( 'Transaction History2019 2020'[Item Number] , [_Average Landed Unit Cost 2019] >0), [_Average Landed Unit Cost 2019] ),
ALL ( 'Calendar'[Date] ),
ALL ( 'Transaction History2019 2020'[Number] ), 'Calendar'[Year] = "2019" )

 

or

 

AVERAGEX (filter( summarize('Transaction History2019 2020', 'Transaction History2019 2020'[Item Number],"_1",CALCULATE ( AVERAGEX ( VALUES ( 'Transaction History2019 2020'[Item Number] ), [_Average Landed Unit Cost 2019] ),ALL ( 'Calendar'[Date] ),ALL ( 'Transaction History2019 2020'[Number] ), 'Calendar'[Year] = "2019" ) ),[_1]>0),[_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello sir, 

 

I have entered the code buit the last part (line4) has some errors... 

 

ERROR.JPG

edhans
Community Champion
Community Champion

This is the corrected measure. Always format the DAX. Makes it easy to see where parenthesis are missing @BigTommy 

 

Measure =
CALCULATE(
    AVERAGEX(
        FILTER(
            VALUES( 'Transaction History2019 2020'[Item Number] ),
            [_Average Landed Unit Cost 2019] > 0
        ),
        [_Average Landed Unit Cost 2019]
    ),
    ALL( 'Calendar'[Date] ),
    ALL( 'Transaction History2019 2020'[Number] ),
    'Calendar'[Year] = "2019"
)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

THANK YOU!

 

This make sense now.

 

I have also tested another solution which replacing ZEROS with NULL in power query... also works!

 

thank you and have  great week!

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.