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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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)
)

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 >?

 

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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