ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
GELÖST

Getword() and the Countword()

mxledesma
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 ANTWORTEN 10

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
Meteor

Thanks

@mxledesma  You're welcome.

Sapna Gupta
Nazia
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
Atom

Try removing the space before "countwords"

Ereon
Meteor

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

 

Rlopez21
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
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)

Beschriftungen
Top-Lösungs-Autoren