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

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #35: Data Cleansing Practice

Sreedhar_2798
5 - Atom

1)  Remove leading zeros

 

For this, I have removed leading zeros using ReplaceChar([Field1], "0", ""),

By this, we are replacing zeros with empty strings.

Here, the point to be noted is, we are lucky with input dataset.

zeros are present only in beginning of every row in "Field1". However, if the zeros are present at different place in the string, we face the risk of the zeros (which are not present at beginning of string) being converted to empty strings. 

 

In order to address this, we can simply convert the data type of the "Field1" from string data type to integer data type using "SELECT" tool. This will remove ONLY the leading zeros. Please find the solution in attached image 

 

Sreedhar_2798_1-1672431342817.png

 

2)  To remove leading zeros , I have used TrimLeft([Field1],"0") in formula tool 

By this, we are trimming the leading  zeros 

To remove the text at the end , we are just changing the data type to "int32" for 'field1" using "select" tool 

Please find the solution in attached image 

Sreedhar_2798_0-1672442098747.png

 

3) To remove ID if it is present at the last, I have used the following in configuration window of formula tool

IF Right([ID],2)="ID" THEN
TrimRight([ID],"ID") ELSE [ID]
ENDIF

Please find the solution in attached image 

 

Sreedhar_2798_1-1672442888953.png

 

4) To achieve the given task, use the following in configuration window of formula tool

IF Length([Safety Code])>8
THEN
Substring([Safety Code],0,8)
ELSEIF Length([Safety Code])=6
THEN
"SC"+[Safety Code]
ELSE
[Safety Code]
ENDIF

 

Please find the attached image for the solution 

Sreedhar_2798_2-1672445335255.png

 

 

TheresaLau
5 - Atom

Here is my ans.

KCParikh
5 - Atom

# 35

FG1
7 - Meteor

My solutions:

TyroneW
Alteryx Alumni (Retired)

Solution attached

hnakabara
7 - Meteor

Completed

lhalliwell
8 - Asteroid
Spoiler
Screenshot 2023-01-04 105149.jpg

Mithun_485
6 - Meteoroid

C35_sol

alisonpitt
11 - Bolide
Spoiler
challenge-35-1.pngchallenge-35-2.png
lizanne_mouton
7 - Meteor

Challenge 35