Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Logical Count Function.

I am trying to calclulate the following: When a certain date is blank, count a related date.

 

IF(IsBlank(A Date)

         ,COUNT(B Date)

                     ,Blank()

 

*This is a direct query with SQL

 

Any tips on how to do this? I am new to PowerBi logic.

14 Replies

  • Hi TSP

     

    Please consider this solution and leave kudos

     

    COUNTBLANK(<columnname>)

     

    this will count the number of rows with a blank value in the column.

    Note it will return 0 if there are rows but no blanks,
    but will retrun blank if the table has no rows at all.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the suggestion, but I am wanting to count "B" Date if "A" date is blank.

       

       

      • speedramps's avatar
        speedramps
        Super User

        Hi again TSP

         

        Please consider this solution and leave kudos

         

        Mycounter =
        CALCULATE(COUNT('MyTable'[MyColumnB),
        FILTER('MyTable'[MyColumnA)=BLANK())
        )
         
        The filter just selects the rows with ColumnA = blank
        then the count counts the remaining rows with a populated ColumnB.
        Any rows with a blank ColumnB will not be counted.