I am trying to count how many cells in a particular column have a higher value than the cell below them. This is how far I've gotten, but it doesn't work (it always returns 0, even if there is at least one cell bigger than the one below it):
=COUNTIF(B4:B500,">"&OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),1,0))
Background (in case anyone is wondering): I am using this to check if the values in this column are properly sorted (ie starting with the lowest value and moving down to the highest). If the formula returns a value greater than 1, I know that the list is not fully sorted.
you could also use an array formula .
{=SUM(N(A1:A13<A2:A14))}
which will check your logical condition for each cell in the array, then convert it to either 0 or 1 by using N()
function and then sum it up. i prefer this approach because, unlike SUMPRODUCT()
, you can use it with other functions than SUM
.
please remember that after inserting an array formula into a cell, you must confirm it by pressing CTRL+SHIFT+ENTER
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.