Forum Discussion

ArchStanton's avatar
ArchStanton
Power Participant
4 years ago
Solved

CountBlanks in Measure

Hi,

 

I want to count the amount of NULL dates there are in a Column when another column is Filtered on "Resolved". 

I have this code but it doesn't work - any help would be much appreciated

 

 

Missing Pre-Resolution Dates = 
    COUNTX ('Cases',
                IF('Cases'[statecode_display] = "Resolved" && 'Cases'[pre_resolutiondate] = "",COUNTBLANK('Closed Cases'[pre_resolutiondate]),1))

 

 

Thanks,

 

  • I've managed to get it to work using this:

     

    Missing Pre-Resolution Dates = 
       CALCULATE(COUNTBLANK('Cases'[pre_resolutiondate]),FILTER('Cases','Cases'[statecode_display]="Resolved"))

5 Replies

  • ArchStanton when you say NULL what does it means, does you column have null values when you check in power query or it is a empty string?

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      So this is in my Data Model so I'm using DAX

      I have tickets where we have missing dates (NULLS) in the pre-resolution date column, I want to count these only when the status code = Resolved, 

      Its almost like an IF formula but when I tried that before it didn't work

       

      hope that makes sense?

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      By NULL I mean there are missing dates so they are blank - I just want to count the blank cells in that column. My code gives you a good idea of what I'm trying to achieve. I cannot use a simple COUNTBLANK because the other column needs to have the condition = Resolved

       

      It's straightforward enough but I'm still struggling

  • ArchStanton I think you didn't get my point, if you go in power query and look at your table, what do you see in the columns, null or what?

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      I've managed to get it to work using this:

       

      Missing Pre-Resolution Dates = 
         CALCULATE(COUNTBLANK('Cases'[pre_resolutiondate]),FILTER('Cases','Cases'[statecode_display]="Resolved"))