Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer and Intelligence Suite.
SOLVED

Using IF and Replace functions

Travis_Ratliff
8 - Asteroid

I have a workflow with data that looks like 

 

company_namecontract_agreementcontract_agreement_ID
Mcdonalds789457529
Popeyes78459 
Zaxbys78421 
Freddys84579 
Popeyes 84124 

 

I am trying to use the formula tool with "IF [customer_company_name] = 'Popeyes' THEN Replace([contract_agreement], "*", [contract_agreement_ID]) ELSE [contract_agreement] ENDIF". To replace all of the different contract agreements that popeyes may have but the current formula is not working. So the new data would look like.

 

company_namecontract_agreement
Mcdonalds78945
Popeyes

7529

Zaxbys78421
Freddys84579
Popeyes 7529

 

Any help is appreciated.

Thanks

4 REPLIES 4
binuacs
17 - Castor

@Travis_Ratliff One way of doing this

binuacs_0-1670254572684.png

 

ShankerV
13 - Pulsar

Hi @Travis_Ratliff 

 

I do have a similar workflow like @binuacs

Please refer to the same.

 

However I noticed, the data you have pasted in the input have trailing whitespaces.

 

Please do use the Data Cleansing tool to remove the Trailing whitespace.

 

ShankerV_0-1670254967543.png

 

ShankerV_1-1670254982907.png

 

 

Many thanks

Shanker V

 

ShankerV
13 - Pulsar

@Travis_Ratliff 

 

Tried one tool solution, please check whether this helps you.

 

ShankerV_1-1670255716777.png

 

ShankerV_2-1670255735410.png

 

Input:

 

ShankerV_4-1670255783063.png

 

 

Output:

ShankerV_5-1670255798412.png

 

 

Many thanks

Shanker V

 

ShankerV
13 - Pulsar

Hi @Travis_Ratliff 

 

Formula 1: Helps to make sure the agreement_ID si filled as 7529 in all the rows.

if (IsNull([contract_agreement_ID]))
then 7529
else [contract_agreement_ID]
endif

 

Formula 2:

IF ([company_name] = 'Popeyes')
THEN [contract_agreement_ID]
ELSE [contract_agreement]
ENDIF

 

Many thanks

Shanker V

Labels