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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
dtartaglia
Resolver I
Resolver I

How to count rows in a specific month/year

Hi,

I'm trying to create a measure that can count the number of rows found within a specific month and year. Thanks for any help!

 

Capture.PNG

 

 

 

5 REPLIES 5
dtartaglia
Resolver I
Resolver I

Hi,

 

Unless someone knows a better way, I created month and year columns from my date column then used this DAX statement:

 

Current Month =
CALCULATE(COUNTROWS(vwServiceDeskWorkOrder), vwServiceDeskWorkOrder[ResolvedMonth] = 8,
FILTER(vwServiceDeskWorkOrder, vwServiceDeskWorkOrder[ResolvedYear] = 2017)
)

AlbertoFerrari
Most Valuable Professional
Most Valuable Professional

You could do that with a simpler measure:

 

=CALCULATE (
    COUNTROWS ( YourTable ),
    MONTH ( YourTable[Date] ) = 8,
    YEAR ( YourTable[Date] ) = 2008
)

Not that your solution is a wrong one (besides, at query time your solution is faster on very large models), just to note that you could do that with a measure. 🙂


Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI

Hi Alberto ,

 

For the below solution this will give only for the month 8th .... Now if i have to present for whole year what is the measure ? can you please advice >?

 

AlbertoFerrari
Most Valuable Professional
Most Valuable Professional

Well, just remove the month part, not that complex 🙂

 

 

Alberto Ferrari - SQLBI

Thanks! I thought I tried that but it didn't work for me. I'll verify again.

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.