Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Padleft

khayitof
7 - Meteor

Hi pros, please help to read this formula. The purpose of the formula is to filter out same-digit numbers. e.g. 111, 4444 or 777.7 etc. I want to understand how the following formula worked. 

 

PadLeft("", Length([Temp_sum]), Left([Temp_sum], 1))=[Temp_sum]

 

khayitof_0-1610625044449.png

 

5 REPLIES 5
afv2688
16 - Nebula
16 - Nebula

Hello @khayitof ,

 

What the formula is saying in this case is:

 

Take the first character from the cell, repeat it itself a number of times equal to the number of characters in each cell.

 

If that number then is equal to the number in the field then "True" else go through "False"

 

Regards

Qiu
20 - Arcturus
20 - Arcturus

@khayitof 
PadLeft("", Length([Temp_sum]), Left([Temp_sum], 1))=[Temp_sum]

1. Left([Temp_sum], 1)) : first character of [Temp_sum]

2. Length([Temp_sum]): Length of [Temp_sum]

3. Meaning creating a string with first character of [Temp_sum] with length of [Temp_sum]

4. Then if it is same with [Temp_sum] itselft, it is true.

5. Basically to check if [Temp_sum] is made of same characters or not.

Same AAAAA, it will true and it will false if its ABAA.

DavidP
17 - Castor
17 - Castor

Hi @khayitof 

 

It's an interesting use of the padleft() function!

 

For is to work Temp_sum has to be a text field.

 

Padleft(String, len, char) is the default configuration for padleft. 

 

In this case:

 

String = "", i.e. nothing

len      = Length([Temp_sum]), i.e. the number of digits in Temp_sum

char    = Left([Temp_sum], 1), i.e. the 1st digit of Temp_sum

 

So the result of PadLeft("", Length([Temp_sum]), Left(Temp_sum,1)) is a string that is the same number of characters as Temp_sum, but the 1st character replicated.

 

The filter tool then tests this against Temp_sum and if they are the same, you know that Temp_sum is a same digit number.

 

 

khayitof
7 - Meteor

@afv2688  Thank you. It was very helpful!

khayitof
7 - Meteor

@Qiu  Thank you, it was very helpful

Labels