Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Converting Excel Countif

Hello Team,

I am new to Power BI.

I trying to convert the excel formula to DAX.

Count Cases Last 31 =COUNTIFS(A:A,$A2,C:C,$C2,B:B,">="&$B2-30)

Sample data is below:

 

Cust Site IDCase Create DateTimeCase TypeCount Cases Last 31
S122456/27/2021 10:18SH2
S122456/28/2021 13:14WO12
S122456/28/2021 19:32CRU2
S122456/28/2021 19:32CRU2
S122457/3/2021 20:53WO12
S122457/18/2021 8:41WO12
S122457/18/2021 8:45WO12
S122457/22/2021 16:52WO12
S122457/22/2021 16:54WO12
S122457/27/2021 2:58WO12
S122457/28/2021 16:28WO11
S122457/29/2021 11:27WO11
S122457/30/2021 16:06SH1
S122458/1/2021 0:20WO11
S122458/1/2021 22:28WO11
S122458/9/2021 0:06WO10

 

 

 

  • There are lots of ways to do this. I'd suggest something like this as a calculated column:

    CountIf =
    VAR CurrRowDate = Table1[Case Create Date Time]
    RETURN
        CALCULATE (
            COUNTROWS ( Table1 ),
            ALLEXCEPT ( Table1, Table1[Cust Site ID], Table1[Case Type] ),
            Table1[Case Create Date Time] >= CurrRowDate - 30
        )

     

2 Replies

  • There are lots of ways to do this. I'd suggest something like this as a calculated column:

    CountIf =
    VAR CurrRowDate = Table1[Case Create Date Time]
    RETURN
        CALCULATE (
            COUNTROWS ( Table1 ),
            ALLEXCEPT ( Table1, Table1[Cust Site ID], Table1[Case Type] ),
            Table1[Case Create Date Time] >= CurrRowDate - 30
        )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your help.