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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jduma
Regular Visitor

Count all non-zero or non-null values at a specific row

Hi all,

 

I am very new to Power BI, but I am loving it already. I am using it to quickly represent and sift through a SQL database. We do a lot of sample testing and I want a way of indicating how many samples are currently remaining since last inspection. I am not sure what would be the best way to do this. For context a 0 is a failed/terminated sample and a null represents a missing sample. 

 

Appreciate any help.

 

SampleMonthsSample Rating (0-10)
11610
1324
1440
6 REPLIES 6
v-chenwuz-msft
Community Support
Community Support

Hi @jduma ,

 

Have your problem been solved? if yes, please mark it as solution so that some one has the same preblem as you can find the answer quickly.

 

Maybe you can try this expression, but befor this you need create a Dimension table for your sample, in order to add one row named "blank/0".

Measure_count =
VAR _1 =
    COUNTROWS ( FILTER ( 'Table', [Sample Rating (0-10)] > 0 ) )
VAR _2 =
    COUNTROWS ( FILTER ( ALL ( 'Table' ), [Sample Rating (0-10)] <= 0 ) )
RETURN
    IF ( SELECTEDVALUE ( 'Dimension'[Sample] ) = "Blank/0", _2, _1 )

Result:

vchenwuzmsft_0-1645696225844.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Samarth_18
Community Champion
Community Champion

Hi @jduma ,

 

You can use measure for it:-

measure = countrows(filter('table','table[Sample Rating (0-10)] = 0 || 'table[Sample Rating (0-10)] = blank()))

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

How would I do it for the current highest months number? IF statement?

Samarth_18
Community Champion
Community Champion

@jduma Could you please elaborate it with example?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

So with the below example at the most recent inspection only sample 2 remains. Sample 1 has failed at 40 months and sample 3 is missing. This is so we can summarize how many samples are still left in the field. A sample of 0 or null(blank) has been removed and no longer requires inspection. 

 

SampleMonthsSample Rating (0-10)
11610
1400
21610
2409
31610
340null
Samarth_18
Community Champion
Community Champion

Try this:-

failed_sample =
calculate (count('table'[Sample]),
    FILTER (
        'table',
        'table'[Sample Rating (0-10)] = 0
    )
)
missing_sample =
calculate (count('table'[Sample]),
    FILTER (
        'table',
        'table'[Sample Rating (0-10)] = BLANK()
    )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors