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.

Query about length function

Mohd-Siddiqui1
8 - Asteroid

Hi there,

 

I am working on some logic using length function but unfortunately I am not getting expected results.

 

I am using IIF(Length([Input]),Replace([Input], "0", "1"),[Input]) for generating Current Output column results.

The above logic is failing for 100 and 0019. Please if you can help me with this.

 

Note: As I am using Length function so I have converted all the numbers into string, but actually they need to have datatype as double in order to use them in the other part of the workflow.

 

InputCurrent OutputExpected output
011
222
   
141414
111
111
100111100
0019111919

0

11

0

11

0

11

 

  
2 REPLIES 2
ChrisTX
15 - Aurora

If you're trying to remove leading zeros, try TrimLeft


TrimLeft(String, y): Removes character in the string (y) from the beginning of the string (String). Y is optional and defaults to trimming white space.

 

Here's a list of all functions:  https://help.alteryx.com/20221/designer/functions

 

The IIF function requires a Boolean data type as the first value.

 

IIF(bool, x, y): Returns x if bool is true, else returns y.

 

You have IIF(Length([Input]),

 

The output of the Length function is a number, so Alteryx converts that number to Boolean, and always gets True.  See below.

 

ChrisTX_0-1664446977273.png

 

Chris

MarqueeCrew
20 - Arcturus
20 - Arcturus

@Mohd-Siddiqui1 

 

I might suggest:

 

IIF(isempty([Input],'',max(1,tonumber([Input]))

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels