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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How COUNTROWS works in this DAX?

rank = COUNTROWS(FILTER(Cars,EARLIER(Cars[Rev])>Cars[Rev]))+1

 

cars.JPG

 

For this DAX, I know that the FILTER will remove any value in Rev. column larger than $950, so they are $0, $240, and $500 in this table.

 

Then how does COUNTROWS work here? 

 

I assume the COUNTROWS work in this way:

 

The COUNTROWS will traverse every number in the list and count how many rows meets the argument.  

 

car3.JPG

For $950, 3 rows meet the criteria (less than $950)

 

For $1170, 4 rows meet the criteria (less than $1170)

 

After plus 1, $950 will be ranked as 4th and $1170 will be ranked as 5th in the list which ranked numbers from small to large eventually. 

 

Is my understanding correct?

 

Thank you in advance! 

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

You understanding of countrows() and earlier() is correct. The countrows() function will count the rows(values) which is less than currect rows(earlier(Cars[Rev])). And if you want to reverse the rank, you can just change ">" with "<" like below:

rank = COUNTROWS(FILTER(Cars,EARLIER(Cars[Rev])<Cars[Rev]))+1

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

You understanding of countrows() and earlier() is correct. The countrows() function will count the rows(values) which is less than currect rows(earlier(Cars[Rev])). And if you want to reverse the rank, you can just change ">" with "<" like below:

rank = COUNTROWS(FILTER(Cars,EARLIER(Cars[Rev])<Cars[Rev]))+1

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

I think the blog below explain the function "earlier" very well, you may refer to the blog:

https://exceleratorbi.com.au/earlier-vs-earliest-dax/

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, I feel like my question is more related to COUNTROWS instead of EARLIER. Sorry for misleading.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors