Create A Calculated Field

data science tableau calculated field

I have just enrolled in a Data Science course on Udemy  and I learned good stuff.

Now is the time to solve the problem of who is winning the bonus.

The first thing to do is clean the dashboard. To do this, click on the « Clear Sheet » button.

data science tableau calculated field

To start we need to create a « Bar Chart » to see the salesperson. In this data, salesperson named « Rep » for representatives.

data science tableau calculated field

To see how many items were sold by each sales representative, you need to put « Rep » in « Columns » and « Units » in « Rows ».

data science tableau calculated field

You can see that the representative who sold the most is Richard.

But we want to have more details. We need to know who is the best representative by region and for now, we can’t see that.

To see this, you put « Region » in « Columns » before « Rep ».

data science tableau calculated field

As you can see, the « Bar Chart » changed. There are separations by region.

In each region, you can see the representatives and the number of items they sold. Alex is the best in Central. Richard is the best in the East and James is the best in West.

To get better visibility, you can order the bars in descending order. Move the mouse over the label « Units » of the bar chart and an icon will apprear. Click on it and the bars will be sorted in descending order.

data science tableau calculated field

Unfortunately, we didn’t answer the question because « Units » is only the number of items sold. What interests us is the amount of money earned by selling the product but we don’t have this type of measure. There is no measure that shows us the total value of sales. There are only « Units » and « Units Price ».

In this case, you have to make a calculation to have the total sales in cash. For each representative, you need to multiply « Units » with « Units Price ».

Let’s look at the data to make a test calculation. Right-click on the « OfficeSupplies » data and click on « View Data ». For example, you see that Nick sold 29 binders to $1.99. So 29 (Units) multiplied by 1.99 (Unit Price) equals $57.71 for this sale.

data science tableau calculated field data science tableau calculated field

In our data, we have no measure where « Units » is multiplied by « Units Price ».

data science tableau calculated field

To solve this problem, you will create an additional measure with a « Calculated Field ». « Calculated Field » si an element that allows us to create measures by calculating quantities.

To create this, right-click in the « Measure » zone and select « Create calculated field… ».

data science tableau calculated field

You can name the calcultated field « TotalSales »

data science tableau calculated field

Select « Units » uses the « * » sign to multiply and select « Unit Price » and click « OK ».

data science tableau calculated field data science tableau calculated field

Now, you can see that your measure « TotalSales » in the « Measure » zone.

data science tableau calculated field

By looking good, you can see that there is an « = » sign before the « # ». This is to indicate that this measure is a calculated field.

Ok, the measure is ready, let’s go. Put « TotalSales » on « Units » to replace « Units » with « TotalSales. Tableau automatically takes the sum aggregate.

data science tableau calculated field

If you want to do this more cleanly, you can remove « Units » by dragging it outside « Rows », then take « TotalSales » and put it in « Rows ».

data science tableau calculated field data science tableau calculated field

Now, that we have a « Bar Chart » with data from « TotalSales », we sort the bars in descending order by clicking here.

data science tableau calculated field data science tableau calculated field

As you can see, the results are different because Richard is no longer the best representatives in the East, it’s Suzanne. The best representative in the East is Suzanne, the best representative at the Center is Mathiew and the best representative in the West is still James.

it’s with the calculated field « TotalSales » that we can know who are the best representatives by region so Suzanne, Mathiew and James earn a bonus.

This was an example to learn how to create a calculated field in Tableau. Have fun creating new calculated field to master this tool that is really useful.

Share this article if you think it can help someone you know. Thank you.


Explanation Of The Challenge And Data


I have just enrolled in a Data Science course on Udemy  and I learned good stuff.

This is the 1st challenge. Use your web browser to go to superdatascience website  to download a data set. In the « Part 1 Visualization » section, click on « Offices Supplies » to download the file « OfficeSupplies.csv ».

data csv file

To organize myself, I created a folder « Visualization » with 3 subfolders. Each subfolder corresponds to the section of « Visualization ». I put the data set « OfficeSupplies.csv » in the 1st subfolder.

data csv file

« OfficeSuplies.csv » is a CSV file. A CSV file is a text file that represents an table but the elements separated by comma.

You can open this CSV file with NotePad++  for PC or with Sublime Text  for Mac.

On the 1st line (column title), we see that we have 6 columns. Each column separated by a comma and the file contains 44 lines.

data csv file

You can also open a CSV file with Excel, OpenOffice  or LibreOffice  to have a table, which is easier to read.

To open a CSV file with Excel, here are the instructions :

  • Open a blank workbook

  • Go to Data tab

  • Click button « From Text » in the general external data section

  • Select your CSV file

  • Follow the Text Import Wizard (in step 2, select the delimiter of your text).

data csv file

This data set contains data from a store that sells office equipment :

  • Order date – date of sale

  • Region – The store is in 3 region (East, Central and West)

  • Rep – salesperson’s first name

  • Item – product’s name

  • Units – product’s quantity

  • Unit Price – price per unit

Each line shows how many sales there were for a product.

The challenge is to help the manager to know who made the most sales per region in the period of this data set. The period of this data set is from July 2014 to June 2015.

The person who made the most sales in each region has a bonus and there are 3 bonus so 1 bonus per region.

It’s will this challenge that we’ll use Tableau Public.

Share this article if you think it can help someone you know. Thank you.


Find The Gym For Your Goals (Part2)

find a gym diffrent type

I read a Nerd Fitness article  and I learned good stuff.

If you didn’t read the part 1, click here 

Type de gyms

different type gym

You noticed there are several categories of gyms. That’s why you have to take your time to think about a gym that fits your needs.

Fitness center franchise

In the best known franchises, you will have cheap membership. It’s cheap but you have few amenities, some type of trainings are forbidden, free weight section is limited and often the staff has no experience.

Health clubs/Sport clubs/YMCA

Clubs look like franchises but they have a better service. There is more amenities, towel service, child care, pool, tennis court. Membership can reach $100, some type of training can be prohibited and free weight’s section limited.

Note : Franchises and clubs can be convenient if you travel a lot because with their membership, you can train in different cities.

Locally owned gyms

These gyms have a better equipement, a free weight’s section bigger and a better quality staff than franchises and health clubs. Membership is around $25-50 and it’s real that amenites are less good than health clubs.

Weightlifting club/barbell club/crossfit

It’s a room with bumper plates, dumbbells, barbells and pullup bar. With the membership, you have a coach and classes, that’s why it’s expensive. These gyms are open at certain hours during the day. These gyms have their own workout program, you can’t do your own workout program.

College/university gyms

it’s cheap and you need to paid upfront in full.

You can have a discount « alumini » memberships if you go to the college or university that you attended. If you don’t live near of you old college/university, some gyms offer memberships to family members of alumini or staff, local « senior » memberships or event just local resident memberships. What is great with this type of gym is you can have acces to their full facilty (pool, racquet courts, classes, etc).

Test drive the gym

test drive

The next step is to look for gyms in your city now that you know differtent types of gyms.

Do a test in gyms to see if the equipement meets your needs. Some gyms offer pass for 1-2 weeks. During the test phase, go train the same days that you plan to train after signing the contract.

Imagine that you find the perfect gym, you sign the contract and eveydays you train, it’s war. The gym is full of people and you can’t use equipement. This is a situation to avoid.

Here is what is important to see during the test phase :

  • Is there enough equipment for everyone or you have to fight to have a bench ?

  • Does the equipment work well ?

  • What is the gym’s atmosphere ?

  • Is it clean ?

  • If you go befoire school/work, is there enough shower available or you have to wait ?

You can read gym’s reviews on internet by searching with Google or DuckDuckGo. Attention, on internet people prefer to complain than to do compliments so be careful. For me the best thing to do is talk to gym members to know what is positive and negative.



A lot of people don’t want to have a membership gym because one of their friend had a bad experience to stop a gym’s membership. This for this reason it’s important to take your time to read the contract and understand clauses.

Here things to look at in a contract :

  • A membership termination clause because for exemple, you move or you lose you job. This is rare but sometimes you can stop a membership if you live near the gym. Usually there is a fee named «  early termination fee » (that’s what I have).

  • The possibility when you’re on vacation ou you have to work for several weeks in another city to freeze your membership.

  • If the gym goes bankrupt, what happens to members ?

  • Membership renewal is automatic ?

You know salespersons work with commission so if a sales person make you a promise, make sure that this promise is in writing. Taking the contract at home is the thing I advise you to read it quietly and understand clauses.

If you feel that the salesperson put pression on you or that you don’t feel comfortable for another reason, leave the gym.

Note : There are states that has specific laws. For exemple, you can cancel the contract only 2 days after signed it. It would be a shame if you signed this type of contract without being aware of this clause. This is why it’s important to take the contract at home to read it quietly.

Here different membership’s fees :

  • Activation fee

    You pay these fees when you’re a new member. You pay these fees once.

  • Monthly cost

    it’s a fee you pay every month

  • Maintenance fee

You pay these fees per year. Attention, some gyms have a special clause that says : « We don’t have this kind of fee now but later, it’s possible to add these fees without telling you ». Be sure to know this clause if it is in your contract.

When I enrolled in my gym, there was an offer for people who applied for registration on internet. Look at gym’s website to know offers but also ask always to salesperson if there are discounts.

In gyms, there is often a membership’s range of price. You need to negotiate, don’t hesitate. Don’t forget that the more you take the more expensive membership, the more the salesperson will have a larger commission. If the salesperson tell you : « No », it doesn’t matter, you tried to get the best price.

By negotiating, somethimes you can register in a gym for the first time without paying the activation fees. To do it, you need to talk to the person who has permission to do this. Sometimes they can call you 1-2 days after to offer you an exceptional offer.

You can also have a nice offer by paying an annual membership up front. Look at the price difference.

Also you can have offers with you health insurance. It’s always with a limited number of gym but look if you have this option.

Stay focus

stay focus

The difference between a workout at home and a workout in a gym is that in a workout in a gym, you can really make your potential evolve to the maximum.

For exemple, if you do a barbell’s workout, you will have always heavy weight plates to go to the next level. It’s the same thing for dumbbells. You need heavier, it’s here. No need to worry about buying new.

Of course, there are negative pointst to enroll a gym. You have to move there (bike, bus, car, etc), you to wait if you go during busy hours, the cost and do your workout around unkown people.

I repeat, you can train at home to be healthy or gain strength with a bodyweight workout program. You can buy a set of dumbbell, barbell, kettelbell or a sandbag. You can do sprints or walk (like my father) outside with any weather and it’s free.

For me the gym, it’s an important moment of my day. It’s the moment where I’m focus on myself and the society’s pressure no longer exists.

Share this article if you think it can help someone you know. Thank you.