Alteryx Designer Desktop Discussions

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

Getword() and the Countword()

mxledesma
7 - Meteor

 I am doing the Try it exercise of the Formula Tool Can anyone explain to me why

 

Formula - GetWord([Address], CountWords([Address])-1) within the Formula tool.

I just dont understand why within Countwords the string has Address and a -1. Why -1. If i omit

the -1 it gives a parse error.

 

10 REPLIES 10
grazitti_sapna
17 - Castor

Hi @mxledesma , as the question says you need to fetch the address suffix therefore, countword(address -1) it reads from backward. If you will use countword(address -2) then it will fetch Jasmine counting second word from the back.

 
 
 
 
 
 
 

 



Thanks!

Sapna Gupta
mxledesma
7 - Meteor

Thanks

grazitti_sapna
17 - Castor

@mxledesma  You're welcome.

Sapna Gupta
Nazia
5 - Atom

@grazitti_sapna pls clarify if i need to use countword or getword to get suffix 

Example : If the address is 376 S JASMINE ST and I need the address suffix (which is the last word of the address then how do I go about?)

Is anyone else getting the error "The field "" is not contained in the record"?  I'm not sure how to interpret this even though I used the same formula as above.

Alteryx Formula - Getword.PNG

Skuhn
5 - Atom

Try removing the space before "countwords"

Ereon
7 - Meteor

You need to create a Column named Suffix.  Currently you do not have the formula tied to any column

 

Rlopez21
7 - Meteor

Example: [Address] - 376 S JASMINE ST

 

Getword() function counts starting at 0. So 0,1,2,3. 

Getword([Address], 0) = returns the very first word of the sentence =  "376"

 

Countword() counts starting at 1. So 1, 2, 3, 4. 

 

Solution

Getword([Address],CountWords([Address])-1)

You have to add -1 because CountWord will return a 4, but GetWord sees the very last word as word #3. 

 

czello
8 - Asteroid

I was working on this same problem in the examples, and what wasn't clear to me was the syntax of wrapping CountWords inside of GetWord.  It kept throwing me an error with CountWords.  The Help documentation only says to enter a string inside the parenthesis, but didn't explain in more detail.  The -1 is the same concept used in Python, when counting from right to left.

 

GetWord([Address],CountWords([Address])-1)

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels