Prompt Detail:
Certainly, as a Tableau user, you can create a line chart with dual axis to see the trend of Sales and Sales Last Year by following these steps:
1. Drag the "Dates" column to the columns shelf and "Sales" to the rows shelf. This will create a line chart with the trend of Sales over time.
2. To add the Sales Last Year trend, you can create a calculated field that calculates the Sales amount for the same time period last year. To do this, right-click on an empty space in the Data pane and select "Create Calculated Field".
3. In the calculated field dialog box, enter a name for the calculated field, such as "Sales Last Year", and enter the following formula:
SUM(IF DATEDIFF('year', [Dates], TODAY()) = 1 THEN [Sales] END)
This formula uses the DATEDIFF function to calculate the number of years between the current date and the date in the "Dates" column, and the IF function to include only the Sales amount for the previous year. Finally, the SUM function calculates the total Sales Last Year.
4. Once you have created the calculated field, drag it to the rows shelf next to the "Sales" field. This will create a second line on the chart showing the Sales Last Year trend.
5. To make the chart dual axis, right-click on the second axis and select "Dual Axis". This will overlay the two lines on the same chart.
6. Finally, you can format the chart as desired, such as by adding titles, labels, and adjusting the axes.
Add a comment