Case with Over Partition by - Not giving results

ROW_NUMBER function (and other windowing functions) operate on the virtual table that is received by the SELECT clause. So, if your goal is that the row_number should count only a subset of those rows ( i.e., rows that do not meet the WHEN clause in your expressions), then windowing functions won't do that.

You would need to generate a virtual table (perhaps using a CTE or a CROSS APPLY construct) that contains only the rows for which you want to apply the row_number function and use the row_number function to that virtual table.