Direkt zum Hauptbereich

Tableau Number Function: ABS




I have been working with Tableau since 2014, but I have still a feeling that my knowledge about this software not good enough. When I rebuild dashboards from tableau.public I am fascinating how some people can create amazing formulas and thus it makes the calculation of data sets easier.

Sometimes I got stuck by creating of graphs and I do some calculations with data in Excel before I visualize them. Otherwise, you can find the definition of every function by creating of calculation field. But, honestly, are this definitions always clearly enough? For me not and I am done by doing long calculations with Excel. 😠 I like my work and I want to have more fun and not do such long calculation with Excel!

I took up a challenge and decided to go through every function in tableau in order to understand how they work. 

I would like to begin with ABS function. 

ABS function is very easy one, as it used to get an absolute value of a number from a negative one. As an example I have chosen two numbers from Super Store: Profit and Sales. At first I would like to generate negative numbers. In order to do that I created a calculation field [Profit]-[Sales] as "negative number". (I know it doesn't make any sense, but on this way I have negative numbers)




In the second step I created a calculation field with ABS function:
abs([Negative number]) as "ABS absolute number" and drop this field to my table: 




And tada... 😍
As you can see tableau convert all negative numbers to absolute numbers.

It was very easy, wasn't it? 




Kommentare

  1. Hats off to your presence of mind..I really enjoyed reading your blog. I really appreciate your information which you shared with us.

    Tableau Online Training

    AntwortenLöschen
  2. Thanks for sharing valuable information. Your blogs were helpful to tableau learners. I
    request to update the blog through step-by-step. Also, find the tableau news at
    Tableau Online Course Blog.

    AntwortenLöschen

Kommentar veröffentlichen

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...

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 ...