Alteryx Designer Desktop Discussions

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

Add white space to meet no of characters in a cell

lawrancehere
7 - Meteor

Hello Everyone, 

 

I have an requirement i tried to solve it but i am unable to do it, Your help or guidance is much appreciated.

 

I want to restrict the no of character in specified cell and if no of character is less than the standard number alteryx should add N no of spaces to meet that no of characters. 

 

Example :

 

Standard No of character for cell A1 is 12

 

A1 contains date as "LAWRANCE" its only 8 character so it should add 4 spaces and output should be like "LAWRANCE    "

 

Hope you understood my requirement, Can anyone support me to find the solution pls. 

 

Regards,

Lawrance Ayyamperumal

8 REPLIES 8
estherb47
15 - Aurora
15 - Aurora
Hi @lawrancehere,

Have you tried the PadRight function yet?

PadRight([field],12, “ “)

It adds text to the end of a string.

Let me know if that helps.

Cheers!
Esther
--
Esther Bezborodko
*Senior Manager*
201.650.7314 | estherbezborodko@gmail.com
beautycounter.com/estherbezborodko

*Our mission is to get safe products in the hands of everyone.*
[image: Facebook]
lawrancehere
7 - Meteor

Its working as expected, Thank you. i will read more about the this function. 

lawrancehere
7 - Meteor

Hi Esther, 

 

Its not adding space wherever numeric character is present , is there any other function available to increase the space in numeric cell ?

lawrancehere
7 - Meteor

one more difficult is  if the cell is null its not writing any white space its simply ignoring cell

estherb47
15 - Aurora
15 - Aurora

Regarding the numbers, PadRight (and PadLeft) only work on text. So, you can convert the columns to text with a select before the function tool, or you can use PadRight(tostring([Field]),12," ")

Alteryx doesn't process nulls through formulas, so you'd have to substitute something else for the null first. Perhaps something like this?

If IsNull([Field]) THEN "            "

ELSE PadRight(tostring([Field]),12," ")

 

Let me  know if that helps.

 

Cheers!

Esther

lawrancehere
7 - Meteor

Hi Esther, 

 

i have tried adding select tool to change the data type as my 1st step but it didn't work i have tried the syntax you shared but even that its not adding space. 

 

for NULL its working fine, Any suggestion for numeric field ?

lawrancehere
7 - Meteor

clipboard_image_0.png

lawrancehere
7 - Meteor

Hi Esther,

 

by any chance did you get time to look into my request ?

Labels