Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

PadLeft / PadRight not working

brandowd
8 - Asteroid

Hi All, 

 

I'm really sorry to ask this as it seems such a stupid question.

 

Whilst digesting some formulas that I'd not used before I was looking at PadLeft and PadRight and tried two very simple scenarios but the results didn't quite match what I was expecting. I'm currently using Designer x64 version 2020.4.5

 

PadLeft (String, len, char)

PadLeft("abc", 4, "x")

PadRight("abc", 4, "x")

 

I was expecting the outputs to be:

xxxxabc

abcxxxx

 

but what I got was

Untitled.png

 

If I change the initial 'string' to just a character then this works but the documentation says this can be a string so I'm a bit confused.2021-07-29 11_55_52-Alteryx Designer x64 - Formula.yxmd_.png

 

I'm really sorry to ask as I know this sounds silly but am I missing something obvious.

 

Thank you.

 

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @brandowd 

 

Use 7 instead of 4. The length is the total length.

 

Hope this helps : )

atcodedog05
22 - Nova
22 - Nova

Hi @brandowd 

 

How Pad functions work is it will add the specified character to left or right to meet the specified length. Observe below example its padding to maintain length 7.

 

atcodedog05_0-1627558114944.png

 

Hope this helps : )

 

ChrisTX
15 - Aurora

The Functions page includes an example for each function:  https://help.alteryx.com/20212/designer/functions

 

From https://help.alteryx.com/

click Designer > Overview, then Functions on the left

 

brandowd
8 - Asteroid

Thanks Chris, I now see the error of my ways. A simple case of PEBCACK. I took the "len" as number of "char" to add rather than total length of string. What a muppet I am.

 

Thank you once again.

Labels