How it works...

The first column, ColumnRank, is extremely simple. This calculation simply uses DAX's RANKX function to rank the rows according to the Value column.

The second column, ColumnRank2, is slightly more complex. The goal of this column is to rank the rows based upon the Value column, but within all related rows based upon the Category1 column; in other words, for two or more rows, having the same value for Category1, which ranks higher based upon the Value column. Thus, if two rows both have a Green for the Category1 column, which row has the higher Value? The DAX FILTER function is used to restrict the ranking performed by RANKX to only those rows in which the Category1 column is the same as the current row's Category1 column. This is done by using the EARLIER function, which essentially returns the current row's Category1 value.

The third column, ColumnRank3, is similar to ColumnRank2, but ranks rows based upon both Category1 and Category2. Thus, for multiple rows having the same Category1 and the same Category2, which row has the higher Value?

It is important to understand this because RANKX is an iterative function. Within a calculated column, the RANKX function supplants strict row context, such that all rows within the table are within the context of RANKX when calculating the rank of any particular row within the table.