Alteryx Designer Discussions

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

Extract last n words from a string

7 - Meteor

Say I have the following table:


A Data Model is a new approach for integrating data from multiple tables.
This parameter is a boolean flag.
I will be going to Germany with my boyfriend this May.
Nobu is a Japanese restaurant known all over the world for its unique food


How can I extract the last x words from each sentence. Is there a function similar to SUBSTITUTE in Alteryx wherein I can replace the xth occurrence of the space or is there another option? The REPLACE function replaces all instances of the character.


Thank you!


6 - Meteoroid

Exactly what I needed.  Very simple.  Sometimes when you ask people what time it is they show you how to build a watch.  Thanks for the time.

6 - Meteoroid

If I understand your problem correctly, you want to split a string to 2 columns by a word in the string.

I come up with this idea which I think is simpler than most of solutions here (at least from the number of tools standpoint). You add a formula tool in which you add 2 columns.

1st column is to extract the last word by the formula: GetWord([field], CountWords([field]) -1)

2nd column is to extract the remaining by the formula: Replace([Page 2], GetWord([field], CountWords([field]) -1), "")

So conceptually, I get the last word to make it 1 column and the rest is the original one with the last word replaced by null.