2 Replies Latest reply on Jun 18, 2018 7:56 AM by paul.winiecki

# How to Rank Customers Based on if a Condition is Met (v10.5)

Hello All,

I'm currently struggling with getting my ranking calculation to output what I would like it to output. I would like to rank the different customers based on how many apples they bought. However, I would only like the rank to increase if the Condition for that customer equals 1. If the customer has a Condition=0, I would like them to receive the rank of the previous customer ranked before them that had Condition=1. In addition, if two customers have Condition=1 and have the same number of apples bought, I would like them to have unique ranks instead of the same rank (whoever receives the higher or lower rank can be random). I've attached a packaged workbook containing the variable Desired Rank (Hard coded but is how I would like the rank to appear) in addition to my attempt at ranking (which is not how I would like the ranking to appear). Any help would be greatly appreciated.

Thanks!

Paul

• ###### 1. Re: How to Rank Customers Based on if a Condition is Met (v10.5)

You were really close Paul.  Here's what I got to work (adjusting your rank attempt formula):

IF ATTR([Condition]=1)

then RANK_UNIQUE(if min([Condition]) = 1 then sum([Number of Apples Bought]) else null end, 'asc')

ELSE PREVIOUS_VALUE(1)

END

• ###### 2. Re: How to Rank Customers Based on if a Condition is Met (v10.5)

Thank you Kyle that is exactly what I needed!