I am trying to make one equation from the two below, but either I am missing something completely simple, or there is a trick to embedding a ranking function into the "AllP