7 Replies Latest reply on Sep 20, 2019 7:23 AM by Jim Dehner

If 2 statements are true

I'm using Tableau 2019.1.3

I'm trying to create a calculation that informs if a product is losing business in the south. Because the product is losing money in the 'South' I want it to populate '1' for the 'Calculation' formula.

Here's my formula:

Calculation

IF [Region] = "South" AND [Profit]<0 THEN 1 END Suggestions on how to fix my formula?

• 1. Re: If 2 statements are true

you want to look at the Product level   so   if you write     {fixed [product]:  max( if(IF [Region] = "South" AND [Profit]<0 THEN 1 END )}

should return a 1 for any product (in this case Chairs although it will look at each product independently -  ) where the profits in the south are negative

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• 2. Re: If 2 statements are true

{FIXED Product:MAX(IF [Region] = "South" AND [Profit]<0 THEN 1 END)}

• 3. Re: If 2 statements are true

you would need to use: Int(  { Fixed [Product] : max ( Region = 'South' AND [Profit] < 0 ) } )

• 4. Re: If 2 statements are true

My 'Profit' is calculation and I get the error "level of detail cannot contain table calculations." What would the solution to this be? The calculation is actually pretty robust, so I may have to spend some time on applying the solution.

• 5. Re: If 2 statements are true

Victor -

don't know with seeing the actual calculation for Profit - it is why we want you to include your twbx workbook

Jim

• 6. Re: If 2 statements are true

Thanks Jim. Conceptually, can you maybe explain what I should try an do as fix? The 'profit' is actually a predicted profit based on various calculations. For example, would the solution, directionally, be that I apply the 'FIXED' LOD to the initial calculation so that it'll carry to the other calculations that ultimately product the 'profit' calculation?

• 7. Re: If 2 statements are true

Victor

sorry once you are  using table calcs the only other calcs they a=can be used in are other table calcs - so my recommendation is to look at how you calculate Profit and see if you can convert that to something that uses lods