7 Replies Latest reply on Mar 1, 2017 6:04 AM by Sherzodbek Ibragimov

IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Dear All,

I've been struggling with this calculation. I've tried it in several different ways but I can't manage to make it work. I need to know which customers are buying 2 products a week.

Essentially the formal would be:

IF Shoes>0 AND Shirts>0 THEN "A" Else "B" END

But when you run it, It first calculates 1 and then the other so its never "B".

Ultimately I want to show just customers that are buying 2 products a week. and ideally the volume in each.

• 1. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Hope this will solve your problem:

1 of 1 people found this helpful
• 2. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Also,

Make sure to duplicate [Type] twice: for Shoes and Tshirts:

Shirts: if [Type]='Shirts' THEN [Type] END

Shoes: if [Type]='Shoes' THEN [Type] END

Last use above formula to determine customers who bought two items in each week.

1 of 1 people found this helpful
• 3. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Dear Sherzodbek,

Thanks so much for your Help!

I'm just having 1 problem with your formula. Did you do anything particular to the date field?

I keep getting this error.

• 4. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Hi Athena,

Week should be written all in small case.

DATEPART('week',[Purchase Date])

Thanks,

Gourav

• 5. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Thanks Gourav,  but I still have the same error

• 6. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

Maybe this?

[A / B Judge]

if ({EXCLUDE [Type]:sum(if [Type]="Shoes" then [Amount] end )}

*

{EXCLUDE [Type]:sum(if [Type]="Shirts" then [Amount] end )})>1

then "A" else "B" end

Thanks,

Shin

• 7. Re: IF Formals: Need to identify if 2 values are present at the same time, but when you run it, it calculates everything individually...

I guess it is due to different versions of Tableau. Workaround could be to create another calculation in a week level and bring that calculation to LOD expression above and it should work.