In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.
SOLVED

How to use if statement to output data into specific format

nkapadia
6 - Meteoroid

I have file with TAX ID data in XXXXXXXXX format from Input file where I need it in specific format in output file. Such as Individual Tax id in XXX-XX-XXXX format and FEIN in XX-XXXXXXX. I have a field called Owner is company. Based on this field, how I should write the If formula that will return output TAX id XX-XXXXXXX if Owner is company is “Y” else XXX-XX-XXXX.

How do I put below statement using IF then Else statement

 

Left([OwnerTaxID],3)+"-"+Substring([OwnerTaxID],4,2)+"-"+right([OwnerTaxID],4)

Left([OwnerTaxID],2)+"-"+right([OwnerTaxID],7)

6 REPLIES 6
ShankerV
17 - Castor

Hi @nkapadia 

 

One way of doing this.

 

ShankerV_0-1682623401422.png

 

 

IF [Owner]="Company"
THEN Left([OwnerTaxID],2)+"-"+right([OwnerTaxID],7)
ELSE Left([OwnerTaxID],3)+"-"+Substring([OwnerTaxID],4,2)+"-"+right([OwnerTaxID],4)
ENDIF

 

ShankerV_1-1682623436080.png

 

 

Many thanks

Shanker V

 

nkapadia
6 - Meteoroid

Thank you. I originally wrote as below but it doesn't generate the result for the FEIN XX-XXXXXXX when OwnerIsCompany = Y. OwnerIsCompany has Y or N value

 

nkapadia_0-1682623557344.png

 

ShankerV
17 - Castor

Hi @nkapadia 

 

Can you please explain as you have applied the formula OwnerTaxID but expecting result to be applied on FEIN.

 

 

Many thanks

Shanker V

nkapadia
6 - Meteoroid

Hello Shanker,

 

Below is my Input 

 

nkapadia_1-1682626244158.png

 

Want to generate the output on OwnerTaxID field based on OwnerIsCompany criteria

 

nkapadia_0-1682625677591.png

 

 

 

ShankerV
17 - Castor

Hi @nkapadia 

 

One way of doing this.

ShankerV_0-1682626682844.png

 

IF ISnull([OwnerCompanyName])
THEN "N"
ELSE "Y"
ENDIF

 

IF [OwnerIsCompany]="Y"
THEN Left([OwnerTaxID],2)+"-"+right([OwnerTaxID],7)
ELSE Left([OwnerTaxID],3)+"-"+Substring([OwnerTaxID],4,2)+"-"+right([OwnerTaxID],4)
ENDIF

 

 

ShankerV_1-1682626701071.png

 

Many thanks

Shanker V

nkapadia
6 - Meteoroid

Thank you so much for the thorough solution. 

Labels
Top Solution Authors