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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ugurgulluev
Helper II
Helper II

Custom column - Average excluding "NA" values

Dear all,

 

I kindly need your expertise for creating a custom column that calcuates the average of several columns. The problem is I have a dataset that includes some "NA" values:

 

WhiteBlackYellowRedCustom column (average of all colors)
3668Error
19NA7Error

 

If I included the "Yellow" column when calculating the average, the custom column gives an error because of the "NA" value.

 

What I am trying is to exclude the cells with "NA" values.

 

Excel is automatically excluding the "NA" values while calculating the average, but it seems that PowerBI does not.

 

Do you guys think of a workaround for this?

 

Thanks for your support in advance.

 

Ugur

3 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Use something along the lines of:

 

Measure = AVERAGEX(FILTER('Table',[Yellow]<>"NA"),[Yellow])

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

sgsukumaran
Resolver II
Resolver II

Option 1: As pointed out use filter in your query

Option 2: Default value to 0 when blank or NA occurs that way your regular calculation would work.

View solution in original post

v-danhe-msft
Employee
Employee

Hi @ugurgulluev,

Based on my test, you could refer to Greg_Deckler's solution, also, you could refer to replace the 'NA' value in query editor:

 1.PNG

 

Hope it could help you.

 

Regards,

Daniel He

Community Support Team _ Daniel He
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

4 REPLIES 4
v-danhe-msft
Employee
Employee

Hi @ugurgulluev,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Employee
Employee

Hi @ugurgulluev,

Based on my test, you could refer to Greg_Deckler's solution, also, you could refer to replace the 'NA' value in query editor:

 1.PNG

 

Hope it could help you.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sgsukumaran
Resolver II
Resolver II

Option 1: As pointed out use filter in your query

Option 2: Default value to 0 when blank or NA occurs that way your regular calculation would work.

Greg_Deckler
Super User
Super User

Use something along the lines of:

 

Measure = AVERAGEX(FILTER('Table',[Yellow]<>"NA"),[Yellow])

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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