Forum Discussion

jl20's avatar
jl20
Helper IV
9 years ago
Solved

Calculated Column akin to COUNTIF

Hi,

 

I am trying to figure out a formula for a calculated column that will count the number of instances of a MatterID number (i.e., the red text in the screenshot below). Every "D" is on the table one time. Then, if the job becomes active, a new "E" record is created with the same MatterID. I searched the forum and could only find examples where multiple tables were involved.

 

This seems like it should be easy, but I can't seem to figure it out. Thank you in advance for your help.

  • To handle that, just wrap the original measure in an IF ISBLANK test:

     

    =
    IF (
        ISBLANK ( YourTable[MatterID] ),
        0,
        CALCULATE (
            COUNTROWS ( YourTable ),
            ALLEXCEPT ( YourTable, YourTable[MatterID] )
        )
    )

     

4 Replies

  • jl20

    A calculated column like this should to the trick:

     

    =
    CALCULATE ( 
        COUNTROWS ( YourTable ),
        ALLEXCEPT ( YourTable, YourTable[MatterID] )
    )
    • jl20's avatar
      jl20
      Helper IV

      That worked, thanks for the quick reply! How would I modify so that if MatterID is blank, it returns a zero?

      • OwenAuger's avatar
        OwenAuger
        Super User

        To handle that, just wrap the original measure in an IF ISBLANK test:

         

        =
        IF (
            ISBLANK ( YourTable[MatterID] ),
            0,
            CALCULATE (
                COUNTROWS ( YourTable ),
                ALLEXCEPT ( YourTable, YourTable[MatterID] )
            )
        )