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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
treack
New Member

Calculating a value in a cell except for Blanks and N/A

Hi, I am trying to calculate a Measure in power BI that returns me a count if a value is present in a cell, except for N/A and blanks, similar to the Total Fruit & Vegetables column below:

 

FruitVegetablesTotal Fruit & Vegetables
AppleN/A1
OrangeCucumber2
 Celery1

 

Does anyone know what is the line of code for this in DAX Power BI?

Thanks in advance

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @treack ,

 

Or Create a measure like this.

Measure = 
VAR __fruit = 
COUNTAX(
    FILTER( Sheet4, Sheet4[Fruit] <> BLANK() && Sheet4[Fruit] <> "N/A" ),
    [Fruit]
)
VAR __vegetables = 
COUNTAX(
    FILTER( Sheet4, Sheet4[Vegetables] <> BLANK() && Sheet4[Vegetables] <> "N/A" ),
    [Vegetables]
)
RETURN
__fruit + __vegetables

v-lionel-msft_0-1597041383589.png

 

Best regards,
Lionel Chen

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

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @treack ,

 

Or Create a measure like this.

Measure = 
VAR __fruit = 
COUNTAX(
    FILTER( Sheet4, Sheet4[Fruit] <> BLANK() && Sheet4[Fruit] <> "N/A" ),
    [Fruit]
)
VAR __vegetables = 
COUNTAX(
    FILTER( Sheet4, Sheet4[Vegetables] <> BLANK() && Sheet4[Vegetables] <> "N/A" ),
    [Vegetables]
)
RETURN
__fruit + __vegetables

v-lionel-msft_0-1597041383589.png

 

Best regards,
Lionel Chen

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

 

harshnathani
Community Champion
Community Champion

Hi @treack ,

 

Steps to follow.

 

You will need to add a Index Column.

 

 

1.jpg

 

Then Select the Index Column and Unpivot ALL other Columns

 

2.JPG

 

Then use the measure

Mea = COUNTROWS(FILTER('Table','Table'[Value] <> BLANK() && 'Table'[Value] <> "N/A"))

 

 

3.JPG

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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