Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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

 

arif0783_0-1632346636189.png

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

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
    )

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

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
Not applicable

Thank you for your help.

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.