For Tableau, can we regex the word before a "word of interest", by creating a Parameter (a list of word of interest)?

Viewed 156

I created the following Calculated Field in Tableau:

REGEXP_EXTRACT(LOWER([Negative Review]), '(\w+)\s+(?=room)')

My aim is to extract the word before "room"

I believe Tableau allows me to extract other words, if my "word of interest" changes. As such, I created a Parameter (parameter name [interest]), consisting of "room, reception, staff". I changed the Calculated Field into this:

REGEXP_EXTRACT(LOWER([Negative Review]), '(\w+)\s+(?=([interest]))')

When I changed the "word of interest" from one word to another, the Calculated Field didn't change (unless the words before room|reception|staff are all the same).

Am I thinking whimsically?

CK

1 Answers

Use concatenation:

REGEXP_EXTRACT(LOWER([Negative Review]), '(\w+)\s+(?=(' + [interest] + '))')
Related