7 Replies Latest reply on Jun 13, 2016 12:07 AM by Vijay Kumar

# Need Help in IF Condition using STARTSWITH

Hi Friends,

I am putting location based on the IP range..

IF STARTSWITH (IP ADDRESS,"10.10") THEN DENVER

The above formula works fantastic but my situation is like below.

10.100 - Denver

10.100.1 - China

10.100.2 - Chicago

I dont know how can I do a condition on the above class for defining the location.

• ###### 1. Re: Need Help in IF Condition using STARTSWITH

Maybe IF STARTSWITH (IP ADDRESS,"10.10") and NOT STARTSWITH (IP ADDRESS, "10.100." THEN DENVER

• ###### 2. Re: Need Help in IF Condition using STARTSWITH

10.100.xx.xx - Denver

10.100.1.xx - China

10.100.2 .xx- Chicago

I have the above scenario which has 10.100.xxx IPs come under Denver but 10.100.1.xx and 10.100.2.xx alone ranges come under 2 different cities

• ###### 3. Re: Need Help in IF Condition using STARTSWITH

Friends I am attaching a sample workbook for this scenario.

I have tried a calculated condition named as Location.

• ###### 4. Re: Need Help in IF Condition using STARTSWITH

Hi Vijay, a simple solution is to place the Denver test last:

```IF STARTSWITH([IP], "10.100.1.") THEN "CHINA"
ELSEIF STARTSWITH([IP], "10.100.2.") THEN "CHICAGO"
ELSEIF STARTSWITH([IP], "10.100.") THEN "DENVER"
END
```
• ###### 5. Re: Need Help in IF Condition using STARTSWITH

Hi John this is not a single situation because like Denver I have scenarios

for multiple locations out of 100 cities in my DB.

• ###### 6. Re: Need Help in IF Condition using STARTSWITH

can you share the IP address and country name sample data for 100-150 rows. I think rather than startswith we should give a try to regular expressions. I can give it a shot if you can provide me mentioned data.

• ###### 7. Re: Need Help in IF Condition using STARTSWITH

Hi Friends,

Got any solution? It's not that I am looking for a formula only with that

starts with and if.. pls suggest me a best solution

On 08-Jun-2016 11:46 am, "Ashish Chaudhari" <tableaucommunity@tableau.com>