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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
MAP
Frequent Visitor

Count records

I have a five years data from 2020 to 2024.I want to count number of records in 2020, 2021,2022,2023 and 2024 separately. in power bi dax

2 ACCEPTED SOLUTIONS
manvishah17
Solution Supplier
Solution Supplier

Hi @MAP , 
you can simply use Count function 
Count_2020 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2020)
Count_2021 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2021)

and so on... or


just put a slicer of year 
RecordCount =
VAR SelectedYear = SELECTEDVALUE(YourTable[YearColumn])
RETURN
CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = SelectedYear)

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1718451420150.png

 

Jihwan_Kim_1-1718451536780.png

 

 

 

Record count: = 
COUNTROWS(sales_fact)

 

Record count 2022: = 
CALCULATE( [Record count:], 'calendar'[Year] = 2022)

 

Rocord count 2024: = 
CALCULATE([Record count:], 'calendar'[Year] = 2024 )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1718451420150.png

 

Jihwan_Kim_1-1718451536780.png

 

 

 

Record count: = 
COUNTROWS(sales_fact)

 

Record count 2022: = 
CALCULATE( [Record count:], 'calendar'[Year] = 2022)

 

Rocord count 2024: = 
CALCULATE([Record count:], 'calendar'[Year] = 2024 )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
manvishah17
Solution Supplier
Solution Supplier

Hi @MAP , 
you can simply use Count function 
Count_2020 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2020)
Count_2021 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2021)

and so on... or


just put a slicer of year 
RecordCount =
VAR SelectedYear = SELECTEDVALUE(YourTable[YearColumn])
RETURN
CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = SelectedYear)

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.