Query about length function
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Input | Current Output | Expected output |
0 | 1 | 1 |
2 | 2 | 2 |
14 | 14 | 14 |
1 | 1 | 1 |
1 | 1 | 1 |
100 | 111 | 100 |
0019 | 1119 | 19 |
0 | 1 | 1 |
0 | 1 | 1 |
0 | 1 | 1 |
|
- Labels:
- Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I might suggest:
IIF(isempty([Input],'',max(1,tonumber([Input]))
cheers,
mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
