5 Replies Latest reply on Feb 8, 2019 8:10 AM by Ritesh Bisht

# Help with calculation

I am trying to do a count of records based on the logic below but for some reason  i am getting the count right for state and not for city and the counts that should technically fall in to city bucket end up in 'NA'.

Can you please let me know what i am doing wrong here. Thanks for your Help !

IF [state] = 'Unknown' Then 'state'

ELSEIF  [city] = 'Unknown' Then 'City'

ELSE 'NA'

END

• ###### 1. Re: Help with calculation

Tableau evaluates calculations sequentially.  What does that mean?

1) Look for any row where [state] is "unknown".  This WILL include rows where [city] is ALSO "unknown"

2) From the rows that are left after evaluating [state], look for rows where [city] is "unknown".

Without seeing your actual data it's hard to tell what's going on to produce the result you're describing.

What you MAY want:

IF [state]='unknown' AND [city]!='unknown' then 'state'

ELSEIF [city]='unknown' then 'city'

ELSE 'NA'

END

• ###### 2. Re: Help with calculation

I want to show this below but the count Tableau is displaying is incorrect. I want to show unknown state counts and unknown city counts separately

IF [state]='unknown' then 'state'

ELSEIF [city]='unknown' then 'city'

ELSE 'NA'

END

• ###### 3. Re: Help with calculation

Mark, read my reply again.  Tableau is counting exactly the way you're telling Tableau to count.  I suggested a different way to count that MAY get you the result you want, but I can't tell because I can't see your data.

You may have to create 2 separate calculations, one just for unknown State, and one just for unknown City.

• ###### 4. Re: Help with calculation

some thing like this -- the count Tableau displaying is incorrect.

• ###### 5. Re: Help with calculation

Hard to tell like this,can you post the workbook ?

Try to isolate the issue and see....

IF [state] = 'Unknown' Then 'state' end ----and see the count ,you may get a hint

IF [city] = 'Unknown' Then 'state' end

IF [state] = 'Unknown' Then 'state'

ELSEIF  [city] = 'Unknown' Then 'City'

ELSE 'NA'

END

Ritesh