Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I am trying to count the number of rows I have by year. The calculation I am using is below but it looks like it is counting all of my rows and not filtering by year because I don't have any events in 2005? Any help would be greatly appreciated.
Solved! Go to Solution.
The issue in your DAX expression is with the placement of the closing parenthesis in the CALCULATE function. You need to move the closing parenthesis for the YEAR function to the correct position. Make sure that the 'eventDate' column in the 'Data' table contains valid dates, and the year is extracted correctly by the YEAR function.
Here's the corrected DAX expression:
2005Count = CALCULATE(COUNTROWS(Data), YEAR(Data[eventDate]) = 2005)
Hi,
You should ideally create a Calendar Table with a calculated column of Year. Create a relationship (Many to One and Single) from the Event Date column to the Date column. To your visual, drag Year from the Calendar Table. Write this measure
Count = countrows(Data)
Hope this helps.
The issue in your DAX expression is with the placement of the closing parenthesis in the CALCULATE function. You need to move the closing parenthesis for the YEAR function to the correct position. Make sure that the 'eventDate' column in the 'Data' table contains valid dates, and the year is extracted correctly by the YEAR function.
Here's the corrected DAX expression:
2005Count = CALCULATE(COUNTROWS(Data), YEAR(Data[eventDate]) = 2005)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 35 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 134 | |
| 96 | |
| 78 | |
| 67 | |
| 65 |