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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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