Forum Discussion
How to count rows in a specific month/year
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)
)
- AlbertoFerrari9 years ago
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- dtartaglia9 years ago
Resolver I
Thanks! I thought I tried that but it didn't work for me. I'll verify again.
- skidambi27 years agoFrequent Visitor
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 >?
- AlbertoFerrari7 years ago
Most Valuable Professional
Well, just remove the month part, not that complex :)