Alteryx Designer Discussions

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

Padleft

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

 

Alteryx Certified Partner
Alteryx Certified Partner

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

15 - Aurora

@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.

16 - Nebula
16 - Nebula

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.

 

 

7 - Meteor

@afv2688  Thank you. It was very helpful!

7 - Meteor

@Qiu  Thank you, it was very helpful

Labels