DEV Community

Cover image for Dealing with the date data type.
daudfernando
daudfernando

Posted on

Dealing with the date data type.

Time is a valuable measure to obtain in an online transaction. With time we can see a trend in each of the available deals. However, it is undeniable that when a database stores the time of a successful transaction, there is segmentation between each time unit.

For example, in the image above, several units of time and date are separate and have their respective columns. This occasion will depend on the case study to be completed. But in this case, we need a date and time in ISO 8601 format.

Not only can this be achieved using SQL queries with the built-in CONCAT function, but Tableau can also do this with the built-in functions provided by creating a new column.

What's the problem?

In this case, we will try to see how big the comparison is between transactions returned by men and women per quarter from 2018 to 2022. Then conclude which gender makes the majority of transaction returns.

Create transaction return date and time

Recall that our data set consists of several columns of time units. We must make this state into one column for the date and time. We will use the MAKEDATE function for dates, which will take three value arguments when used.

MAKEDATE Function

Ensure the order of input arguments is appropriate and must also be type integer yes. So the return date column will be like this:

Return date

As with time, in Tableau, we will use the MAKETIME function.

MAKETIME Function

Thus the return time column will be created as follows:

Return time

Once you've successfully created the date and time columns, it's time to make all of them into a timestamp. This time we will use the MAKEDATETIME function.

MAKEDATETIME Function

And the column that we create becomes like this.

Timestamp field

Transactions and returns, which is more?

Let's create a line chart representing the changes in these two metrics per successive quarter. So the steps taken are:

  1. Create a row in a new sheet with COUNT DISTINCT of total transactions returned and TOTAL quantity of transactions received.
  2. Compare the two values ​​based on time with continuous units of quarters.
  3. Don't forget to change the two measurements in rows to dual axes, so they stand on the same Cartesian chart.

Return Ratio

Do not be fooled

At first glance, the line chart shows that the returned transaction is greater than the entire transaction. This chart can present a bias for our audience and must be adjusted to show the percentage between the two line charts. The method :

  1. Create a new column named % of return, which results from the division between the total transactions returned and the complete transactions.
  2. Change the data type format to a percentage with a precision of one digit after a comma.

So that the trend of the returned transactions can be seen on this line chart.

Return Ratio

So, is it a woman or a man?

The last step that needs to be done is to see the comparison between men and women, who often return their transactions. We can achieve this goal by giving a Marks Card in the color section of a Gender column consisting of Male and Female so that it becomes a line chart between the two sexes.

Marks Card gender

Look, it turns out that the female gender is the majority of customers who make transaction returns. This uniqueness certainly needs further analysis!

Gender Return Ratio

Top comments (1)

Collapse
 
tijundonghua profile image
tijundonghua

The stats are amazing Drift F1