I have an address field for which I am trying to extract the country during data preparation. For example:
123 West St, Washington, DC 20005, USA
or
100 Main St STE 700, Office 754, Washington, DC 20004, USA
Note that they don’t have the same number of elements in the address. I want to extract that last element in order to get the country.
I have tried using:
split(
{address},
“,”,
strlen({address})-strlen(replace({address}, “,” ,“” ))
)
however, I get an error when trying to use the strlen/replace combination in the split function in data preparation.
I have no control over the form of the address I receive, so have to deal with it as is.
Any suggestions for how I extract that last element in a string?
Thank you both. There must be something odd with my dataset. When I try with a static string like in your code above, it works fine. But when I try it substitute with the actual field name {address}, and then try to publish it, I get
Hi @JMthinkrf Did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community Q&A Forum!
Unfortunately, no it did not work in a calculated field during data preparation. I didn’t get an error when I used a static string like in ErikG’s example, but when I substituted that static string with a string field, I got an error.
I ended up using nested ifelse statements to extract the last field based upon the number of commas: