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! Request now

Reply
rile14
Helper I
Helper I

How to count blanks as Failed?

Hi All,

 

I have two columns, Status and ID. In Status column I have 3 values: blank, Failed and Succeeded. What I need is to display a count of ID's per Status, where blanks should be counted as failed.

rile14_0-1630507031765.png

So, here I would filter a visual to display just Failed and Succeeded, but to see 15 under Failed (Failed + blanks) and 61 under Succeeded.

 

Can someone help me on how to solve this?

 

Thanks in advance.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@rile14 Can you consider replacing the blannk ones, with failed status in data model?

 

View solution in original post

Fowmy
Super User
Super User

@rile14 

The best approach is to replace blank with Failed in Power Query in your data source. 

If you need  a dax solution the create a measure as follows but you need to filter out the balnk in filter pane to get a better pciture

 

M2 = 
VAR __Status = MAX(Table5[Batch Status]) 
Return
SWITCH(
    TRUE(),
    __Status = "Failed" , 
        CALCULATE(
            COUNTA(Table5[Batch Status]),
            Table5[Batch Status] <> "Succeeded"
        ),
    COUNTA(Table5[Batch Status])
)

 

My data

Fowmy_0-1630508893947.png

 

Result (I unchecked Blank)

 

Fowmy_1-1630508934924.png

 

 

 

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

Hi @rile14 

 

Try this measure:

 

Count Status =
VAR _CSucceeded =
    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Status ] = "Succeeded" )
RETURN
    IF (
        MAX ( 'Table'[Status ] ) = "",
        BLANK (),
        IF (
            MAX ( 'Table'[Status ] ) = "Succeeded",
            _CSucceeded,
            COUNTROWS ( ALL ( 'Table' ) ) - _CSucceeded
        )
    )

 

 

You don't need to set any filter.

 

My table:

VahidDM_0-1630571237180.png

Output:

VahidDM_3-1630571417390.png

 

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

Appreciate your Kudos VahidDM_2-1630571298895.png !!

Thank you Vahid. Your solution works the same as the one provided by @Fowmy  But with both solutions there is another issue now. The total is not correct:

rile14_0-1630572005193.png

Do you know how this could be fixed?

Thanks.

Fowmy
Super User
Super User

@rile14 

The best approach is to replace blank with Failed in Power Query in your data source. 

If you need  a dax solution the create a measure as follows but you need to filter out the balnk in filter pane to get a better pciture

 

M2 = 
VAR __Status = MAX(Table5[Batch Status]) 
Return
SWITCH(
    TRUE(),
    __Status = "Failed" , 
        CALCULATE(
            COUNTA(Table5[Batch Status]),
            Table5[Batch Status] <> "Succeeded"
        ),
    COUNTA(Table5[Batch Status])
)

 

My data

Fowmy_0-1630508893947.png

 

Result (I unchecked Blank)

 

Fowmy_1-1630508934924.png

 

 

 

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you for helping me with this.

Unfortunately I can't replace blanks in data source.

 

DAX would be perfect solution for me. Result from your example is what I need. But when I tried to apply that DAX on my case I got different result:

rile14_0-1630570122570.png

First column is just count of IDs and in second column is measure that you provided. Blank is not visible, but still it's not added to the Failed count. I would expect to see 15 under Failed.

Am I missing something?

M2 =
VAR __Status = MAX('Batch'[BatchStatus])
Return
SWITCH(
TRUE(),
__Status = "Failed",
CALCULATE(
COUNTA('Batch'[BatchStatus]),
'Batch'[BatchStatus] <> "Succeeded"
),
COUNTA('Batch'[BatchStatus])
)

UPDATE: I fixed this. I just needed to count batch id instead of batch status. Thank you very much. 🙂

 

 

Anonymous
Not applicable

@rile14 Can you consider replacing the blannk ones, with failed status in data model?

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors