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
rank = COUNTROWS(FILTER(Cars,EARLIER(Cars[Rev])>Cars[Rev]))+1
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.
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!
Solved! Go to Solution.
@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.
@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.
@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.
Hi, I feel like my question is more related to COUNTROWS instead of EARLIER. Sorry for misleading.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!