1 2 Previous Next 18 Replies Latest reply on Feb 22, 2017 11:18 AM by Sagar Sanjay Joshi

# what is wrong in if else calculation

if [Region]= "NE" then '94768796'

ELSEIF  [Region]= "NE" then '93927594'

ELSEIF   [Region]= "WEST" then '93927595'

END

• ###### 1. Re: what is wrong in if else calculation

You really don't see it?

• ###### 2. Re: what is wrong in if else calculation

You have "NE" there twice. Replacing that should work.

• ###### 3. Re: what is wrong in if else calculation

I have a condition if Region is NE then code should be 94768796 and 93927594 and for west it should 93927595.

But I am using the same in filter it giving me only 94768796 and 93927595 not 93927594

I am not getting what wrong with the calculation

• ###### 4. Re: what is wrong in if else calculation

You can't have 2 values for the same thing though.  When [Region] = NE you will never get to the ELSEIF.

2 of 2 people found this helpful
• ###### 5. Re: what is wrong in if else calculation

My end goal is this.

I have a condition if Region is NE then code should be 94768796 and 93927594 and for west it should 93927595.

then what should be the condition

• ###### 6. Re: what is wrong in if else calculation

The problem is there is no logic when the code should be 94768796 or when it should be 93927594. Using the logic in your calculation, Tableau won't know when to return either of the two values.

Is there some other piece of information that determines whether something is 94768796 or 93927594 besides [Region]?

• ###### 7. Re: what is wrong in if else calculation

You can have NE equating to 2 values though .... think of it in Excel terms ...   in the first column you have NE, in the cell beside that you can only have 1 value - 94768796 OR 93927594 , but not both

• ###### 8. Re: what is wrong in if else calculation

What is the unique identifier to determine 94768796 and 93927595 within same "NE".

Without that, you can not achieve your goal.

Thanks,

Shin

• ###### 9. Re: what is wrong in if else calculation

Apart from Region I do  not have other thing to use.

• ###### 10. Re: what is wrong in if else calculation

Agree with you but I do not have other way to go.

Region  Code

NE         94768796

NE         93927594

WEST    93927594

• ###### 11. Re: what is wrong in if else calculation

So there must be another column to make the 2 NE rows different.

• ###### 12. Re: what is wrong in if else calculation

sorry

correct values are

Agree with you but I do not have other way to go.

Region  Code

NE         94768796

NE         93927594

WEST    93927595

Basically i am struggling with blending the data with other data sources So I thinking to use idea. If I select a region as region then all the data should populate for the specific code,

• ###### 13. Re: what is wrong in if else calculation

You keep circling the drainpipe on the IF statement but it's already been made clear that an IF statement will evaluate to a single value for each record

Thus, if you have an IF statement like
IF [Region] = 'NE' then 1234

ELSEIF [Region= 'WE' then 4567

ELSE 8910

END

And you have three records as follows:

 Region OrderId NE 100 NW 200 WE 300

The IF statement will evaluate for each record as follows

 Region OrderId IF Statement NE 100 1234 NW 200 8910 WE 300 4567

It sounds like you're trying to achieve something else, but it's impossible to know what without some sample data. Please create a sample and attach a Tableau Packaged Workbook where we can replicate your problem.

2 of 2 people found this helpful
• ###### 14. Re: what is wrong in if else calculation

so are you just trying to blend your primary data source with 2 different secondary sources? 1 that has NE = 94768796 and 1 that has NE = 93927594?

if so just create 2 different calculated fields:

[Data source 1 blend] =

Case [Region]

when "NE" then "94768796"

when "WEST" then "93927595"

end

[Data source 2 blend] =

Case [Region]

when "NE" then "93927594"

when "WEST" then "93927595"

end

and then set the relationships to the data sources respectively.

if this is not what you are trying to accomplish can you give us a broader picture of what you are trying to do? maybe there is a different way to approach it.

1 2 Previous Next