Direkt zum Hauptbereich

I want to understand RegEx! (Part2)



It is already two weeks ago since my last blog post. This two weeks I spent in Scotland. It is a very beautiful country with unforgettable landscaps. However, it is not the topic I want to talk about. In this blog I will continue the topic about the RegEx and its using in Tableau.

Tableau offers you four different uses cases of RegEx:
REGEXP_EXTRACT
If you have data like this: aspirin_20_mg_oral_tablet and you would like to extract onliy 20_mg.
What I do is I check my RegEx on this web site: http://regexr.com/










If it is ok, put this RegEx in Tableau function: REGEXP_EXTRACT([0-9][0-9]+[_]+[a-z]+) and extract all "20_mg"


REGEXP_EXTRACT_NTH

The same like the function before but here you can limit your extract to Nth index. Image you have data like this: aspirin_20565435 and you want to extract only "aspirin_20". So your formula should be: REGEXP_EXTRACT_NTH([a-z]+[0-9], 2)


REGEXP_MATCH
It is very easy one: Using REGEXP_MATCH we can find if the string the matches with entered pattern or not. If the string matches with the pattern it return true else false.
REGEXP_REPLACE
If you would like to replace somethin into something, then use this function.
Example: I want to replace all "aspirin_20_mg_oral_tablet" by space " ". My RegEx is: 
REGEXP_REPLACE ([a-z0-9], ' ')


Here you can find more to RegEx: 
Regular Expressions In Tableau

Best
Dilyana


Kommentare

Beliebte Posts aus diesem Blog

Tableau Table Calculation Function: WINDOW - Functions

The functions which begin with „WINDOW_...“ are also common used in Tableau. Remember! The “WINDOW_” function stays for the offset in data set, so-called WINDOW. It can look like this: 1) You can see the “WINDOW” clearly because of separation line between rows: 2) You limit the “Window” by giving the information about the first and the last row number. In this case, you give Tableau the information about the data offset. Let's have a look at the example with WINDOW_SUM I created a sample with data from Superstore. I would like to have a total sum of Sales in every row. In order to do this I created a calculation field: WINDOW_SUM(SUM([Sales]), FIRST(), LAST()) With this formula I said to Tableau: “Hey Tableau, calculate the total sum of sales from the first till the last row in the data set” And this is the result: Tableau wrote the result (total sum of Sales) in every row. As another option you can cumulate the result in each row and...

How create a calender with tableau?

I posted a calendar to tableau public, which I have done with Tableau 9.3. In my first blog I would like to share with you the steps for creating a calendar. The data sources and calendar you can find here. There are different reasons to use a calendar in tableau e.g. You can create your own calendar with an individual format and a lot of appointments. So it will help you make planning better.  You can also analyze things with calendar, if you drop&down a relevant dimension in order to show successful or not successful days.  To create such things is just a training and will help you use dimensions&figures on another way. And thi is my approach: I created a spreadsheet in excel with three columns: Date  Type of holiday  Holiday The column "Type of holiday" is necessary in order to make differences between private and official holidays. With the spell "C" I marked all private birthdays and with the spell "F" all offici...

Rebuilding an old article in a modern one

I tried to improve some graph what I found online on the page of NewYork Times. The article is about the relationship between driving habits and gasoline prices in the period from 1956 until 2010. In this article I found some interesting graph: It is informative graph was created 2010. I wonder how it will look like if I created this graph today with tableau? And here is my result: What become better?  - at first sight you can recognize deepest and highest prices as the color red signaled something negative. The blue means something positive in this case. - I added the average line, so you can estimate if the prices are over or under the average - I made x aches a bit longer in order not to be deceived with price development. If you let data talk it is important not to overdone with visualization. Some changes look positive (e.g. 1990) but prices are still in the negative area. On the original graph it is difficult to recognize this. There are some hi...