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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
PJC83
New Member

COUNTROWS that match a certain value (date)

Good Morning,

 

I'm really struggling with this one in DAX as it'd be so simple with Excel.

 

Bascially, I have been sent a dataset with the due date of a project formatted in yyyy-mm:

 

PJC83_0-1646740452727.png

 

How would I create a calculation to count the rows that match the current month? (2022-03) - a calculation that updates as the months pass and therefore the current month value changes.

 

Many thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

As a shortened form of the other answer, you can use :

 

Count of due dates this month =
COUNTROWS(FILTER(TableName, TableName[Target Date Month(If known)]= FORMAT(TODAY(),"YYYY-MM")))

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

As a shortened form of the other answer, you can use :

 

Count of due dates this month =
COUNTROWS(FILTER(TableName, TableName[Target Date Month(If known)]= FORMAT(TODAY(),"YYYY-MM")))

 

 

Richard_100
Resolver I
Resolver I

Hello

 

The answer depends on your data model set up, so at a top level you need a calculation like this one, but potentially with the VARs adjusted according to your model if you need something more sophisticated:

 

Countrows Current Month:=
VAR CurrentYear = FORMAT(YEAR(TODAY()), "0000")
VAR CurrentMonth = FORMAT(MONTH(TODAY()), "00")
VAR CurrentYear_Month = CurrentYear & "-" & CurrentMonth

RETURN COUNTROWS(FILTER(Data, Data[Target Date Month (If Known)]=CurrentYear_Month))

 

Richard_100_0-1646741234542.png

 

 

Hope that helps

 

Regards

Richard

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.