8 Replies Latest reply on Apr 30, 2018 4:26 PM by Deepak Rai

# creating a range and then using it to rank

As a new Tableau user I am not too familiar with some cncepts. Any help is appreciated

I need to find total of sales by customer, which I can do by creating a variable   maxsales as sum(sales).

Once maxsales for each customer is created, next  step is to create a range and group it in 5 classes of maxsales

I created a new variable range as  (max(maxsales) - min(maxsales))/5; I need to keep this constant when I assign ranks (however this changes with each customer)

I created ranks using ranksales as

if maxsales <min(maxsales) +range then  5

elseif maxsales <min(maxsales + 2* range then 4

etc.

problem I have is range keeps changing based on each customer . any help would be appreciated

I guess my question is how can I keep range as constant number and not change with each customer; same for ranking within group. Thanks

 customer sales 1 24.95 2 24.95 3 24.95 4 7.99 1 15.98 1 7.99 2 7.99 3 7.99 4 15.98 5 7.99 5 15.98 3 9.99
• ###### 1. Re: creating a range and then using it to rank

what are the expected results from above data?

• ###### 2. Re: creating a range and then using it to rank

If you want your range not to chnage per Customer, then you need to use this

• ###### 3. Re: creating a range and then using it to rank

Deepak

Thanks. This only gives me range for the original data, I want the range after summing the data by customer. Example

I want the range (max (which is 48.92) - min (which is 23.97))/5=4.99

3.392 comes from raw data (24.95-7.99)/5

I tried the following

({fixed: MAX([maxsales])} - {fixed: MIN([maxsales])})/5

maxsales is sum(sales) which I created in Tableau

this gives an error

argument to max is already an aggregate function and can not be further aggregated

Thanks

 Row Labels Sum of sales 1 48.92 2 32.94 3 42.93 4 23.97 5 23.97
• ###### 4. Re: creating a range and then using it to rank

Hi Anil,

Here it is

Thanks

Deepak

If it Helps, pl mark it Helpful and CORRECT to Close Thread

1 of 1 people found this helpful
• ###### 5. Re: creating a range and then using it to rank

Thanks it works!!!!

1 of 1 people found this helpful
• ###### 6. Re: creating a range and then using it to rank

Great!!! Pl close The Thread by Marking my Reply as CORRECT, The CORRECT button is under my Reply in your this main Thread, not in email.

1 of 1 people found this helpful
• ###### 7. Re: creating a range and then using it to rank

I clicked on “correct answer” in your reply, That should close it I think.

• ###### 8. Re: creating a range and then using it to rank

yes Thanks