3 Replies Latest reply on Mar 16, 2016 6:08 AM by Shinichiro Murakami

# Recursive Bins

Hi Team,

Happy Sunday!

I am trying to create bins based on one of the product in a list and report the rest of the products based on the specific product bins.  I use the following data as an example:

Customer
ProductPriceUnit
1A\$23
1B\$125
2A\$36
2B\$144
3A\$23
3B\$155
4A\$46
4B\$144

• I wanted to create 2 price bins based on product A, \$1-\$3 and \$3-\$5
• And would like to report the number of units of product B for those customers who purchased product A based on the 2 bins above.

The following is the summary report that I would like to generate in Tableau:

Prod A Price BinsProduct A - UnitsProduct B - Units
\$1-\$31214
\$3-\$564

I created a calculated field for the bin

IF [Product] = "A" THEN

IF [Price] >1 AND [Price] <=3 THEN "\$1-\$3"

ELSEIF [Price] >3 AND [Price] <=5 THEN "\$3-\$5"

END

END

But when I tried to create the report, Tableau group product B unit as null.  Is there a way to force Tableau to return the corresponding product B units to the appropriate bins for product A?

Thank you in advanced for the help!!!

• ###### 1. Re: Recursive Bins

Here you go.

[Price A]

if [Product]="A" then [Price] END

[Prod A Price Bins 2]

if {fixed [Customer]:min([Price A])}<=3

then

"1-3 Customer"

elseif {fixed [Customer]:min([Price A])}>3

then

"3-5 Customer"

END

Thanks,

Shin

9.2 attached

• ###### 2. Re: Recursive Bins

Thank you very much Shin!!!

• ###### 3. Re: Recursive Bins

You are very welcome!!!

Thanks,

Shin