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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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