The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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!
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
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 🙂
Thanks! I thought I tried that but it didn't work for me. I'll verify again.
User | Count |
---|---|
70 | |
67 | |
63 | |
50 | |
28 |
User | Count |
---|---|
113 | |
78 | |
64 | |
55 | |
44 |