9 Replies Latest reply on Jun 30, 2016 3:03 AM by Ashish Chaudhari

# How to write this logic

In sample super store data source

I have to write a logic to find out cutomers who

Belong to Year 2013 and Purchased from category Furniture and Belong to East region and if he is among top 10 customers ?

I need to get calculated column which has customers who fit with above conditions.

I tried  several  ways but i cold not get it .

• ###### 1. Re: How to write this logic

Hi Jessy

You can do this!!

But you need to do it over multiple fields...

First the sales

IF YEAR([Order Date])=2013 AND [Category] = 'Furniture' AND [Region] = 'East' THEN [Sales] ELSE NULL END

Next the rank

RANK_UNIQUE(SUM([2013 East Furn Sales]))

Finally the display filter

IF [Rank] >= 1 and [Rank] < 11 THEN 'DISPLAY' ELSE 'HIDE' END

Set to DISPLAY, done

example to follow

Cheers

Mark

1 of 1 people found this helpful
• ###### 2. Re: How to write this logic

9.3.3 attached.

• ###### 3. Re: How to write this logic

Belong to Year 2013 and Purchased from category Furniture and Belong to East region and if he is among top 10 customers ?

or did you only want male customers?!

• ###### 4. Re: How to write this logic

Hi Jessy,

Please find the attached workbook and confirm the output. Below is the calculated field that I have used.

if RANK(SUM(IF YEAR([Order Date])=2013 and [Category]="Furniture" and [Region]="East" THEN [Sales] END),'desc')<=10 then "Belongs to top 10"

ELSE "Doesn't belongs to top 10"

END

Validation

Thanks and Regards,

Ashish Chaudhari

2 of 2 people found this helpful
• ###### 5. Re: How to write this logic

That's too fast Mark. Good humor as well. So did you just gave 'Male' Customers or overall top 10?

• ###### 6. Re: How to write this logic

Nice, Ashish!

@jessy - mine and Ashish's answers are the same... the only difference is the RANK vs RANK_UNIQUE or other RANK functions can make a difference what is included in the top10.

His does it in 1 step, I broke mine out for demo, either works, just be aware of the different RANK functions

2 of 2 people found this helpful
• ###### 7. Re: How to write this logic

Yes Mark. I am learning from you.

• ###### 8. Re: How to write this logic

I'll let you (and Jessy) into a little secret...

@jessy_cool was the first person I ever helped on the forum, when I see (him/her?), I always try and help, like a guardian Tableau angel.

(and logic statements are a favorite of mine!)

@ashish, I noticed you around the forum more - keep up the good work, it doesn't go unnoticed

All the best

Mark

• ###### 9. Re: How to write this logic

Thanks for your kind words Mark.

Surprised that you still remember whom you have first responded/help.

-Ashish