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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
johnbird
Regular Visitor

How to replicated this countifs in PowerBI

Hello, 

I have a table below with a list of ID and dates. A [BindingID] will be repeted for each [ReportingPeriod] if it has been picked in that month. The Binding ID will only apprea once for each month. I want to  replicate the countifs formula I use in Excel in this table in PowerBI "=COUNTIFS($A$2:$A$586,A2,$C$2:$C$586,D2)"

 

So far I have this DAX function but it does not return anything. "

Issue_LastMonth = CALCULATE(COUNTA(dq_issues_tbl[BindingID]),FILTER(dq_issues_tbl,dq_issues_tbl[BindingID] = dq_issues_tbl[BindingID] && FORMAT(dq_issues_tbl[ReportingPeriod],"DD/MM/YYYY") = FORMAT(dq_issues_tbl[LastMonth],"DD/MM/YYYY")))"
 
Is there a way this can be achiveved within PowerBI.

 

BindingIDDQItemIDReportingPeriodLast Month Issue Last Month
684129/02/202431/01/20241
1439629/02/202431/01/20241
19612929/02/202431/01/20241
25716729/02/202431/01/20241
29818829/02/202431/01/20241
43229029/02/202431/01/20241
43429229/02/202431/01/20241
44970929/02/202431/01/20240
45232829/02/202431/01/20240
46131029/02/202431/01/20241
47754829/02/202431/01/20241
47954929/02/202431/01/20241
51232929/02/202431/01/20240
55571029/02/202431/01/20240
68655229/02/202431/01/20241
76033129/02/202431/01/20240
80671429/02/202431/01/20240
80951929/02/202431/01/20241

 

Thanks John

1 ACCEPTED SOLUTION

Ok so I decided to ask Microsoft Copilot and it actually worked. This is the solution:

 

Column =
VAR BindingID = dq_issues_tbl[BindingID]
VAR ReportingPeriod = FORMAT(dq_issues_tbl[LastMonth],"DD/MM/YYYY")
RETURN
    COUNTROWS(
        FILTER(
            ALL(dq_issues_tbl),
            dq_issues_tbl[BindingID] = BindingID &&
            FORMAT(dq_issues_tbl[ReportingPeriod],"DD/MM/YYYY") = ReportingPeriod
        )
    )
 
Thank for taking a look, Cheers John

View solution in original post

4 REPLIES 4
aduguid
Super User
Super User

Give this DAX measure a try

Issue_LastMonth = 
CALCULATE(
    COUNTROWS(dq_issues_tbl),
    FILTER(
        dq_issues_tbl,
        dq_issues_tbl[BindingID] = EARLIER(dq_issues_tbl[BindingID]) &&
        FORMAT(dq_issues_tbl[ReportingPeriod], "DD/MM/YYYY") = FORMAT(dq_issues_tbl[Last Month], "DD/MM/YYYY")
    )
)

Thank you for the quick reply, unfortunatly it returns blank in the column.

@johnbird Seems like that would be expected behavior. None of your rows have a ReportingPeriod that is equal to the Last Month so it's going to filter out all rows.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Ok so I decided to ask Microsoft Copilot and it actually worked. This is the solution:

 

Column =
VAR BindingID = dq_issues_tbl[BindingID]
VAR ReportingPeriod = FORMAT(dq_issues_tbl[LastMonth],"DD/MM/YYYY")
RETURN
    COUNTROWS(
        FILTER(
            ALL(dq_issues_tbl),
            dq_issues_tbl[BindingID] = BindingID &&
            FORMAT(dq_issues_tbl[ReportingPeriod],"DD/MM/YYYY") = ReportingPeriod
        )
    )
 
Thank for taking a look, Cheers John

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors