Let $x$ be the minor number and $y$ be the major number. It looks easier to me to count downward because there is one tile with $x=6$, two tiles with $x=5$ and so on. There are $\frac 12(6-x)(7-x)$ tiles in the rows with minor numbers greater than $x$ so the last index in the row above $x$ is $28-\frac 12(6-x)(7-x)$. Now we count down $7-y$ tiles in the current row, giving a final result of $$21-\frac 12(6-x)(7-x)+y$$