Dealing with the date data type.
Published: 2022-06-23 08:52:57

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tdaqvi792yxxo8nzwof.png)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sc5p6ens7zfrri4w5f5.png)
 
As with time, in Tableau, we will use the MAKETIME function.

![MAKETIME Function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fx003408pgwt8psxk18n.png)
 
Thus the return time column will be created as follows:
 
![Return time](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hrph5cedszkra162exx.png)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s5wzm2xg8ood8g4hczy.png)
 
And the column that we create becomes like this.

![Timestamp field](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7ptm94ffl9qt9cfohgl.png)
 
## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsr0qwapkktyxgfglm0r.png)
 
## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlx8e7arcocvtgqhtgve.png)
 
## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adk1fr8yv3528iqkekwk.png)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d99rcx2oons40cuuft6i.png)