Dynamic Visualization with Parameter in Tableau

Parameter là một tham số trong workbook, có thể ở dạng số, thời gian hay một chuỗi ký tự có thể thay thế các hằng số trong một phép tính, bộ lọc, hoặc một đường tham chiếu. Nhìn chung thì Parameter hoạt động khá giống bộ lọc.
A parameter is a workbook variable such as a number, date, or string that can replace a constant value in a calculation, filter, or reference line. Generally speaking, Parameters are executed like filters.

Trong bài viết này, mình sẽ hướng dẫn các bạn sử dụng parameter trong Tableau.
This post is to guide you through parameters in Tableau.

1. Create Parameter

Cách 1: Click phải chuột vào khoảng trống trên Data Pane → Create Parameter
Method 1: Right-click on space in Data Pane → Create Parameter

Cách 2: Click vào dấu mũi tên bên cạnh nút View trên Data Pane → Create Parameter
Method 2: Click on down arrow next to view button on Data Pane → Create Parameter

Name: đặt tên cho parameter
Data type: chọn kiểu dữ liệu (Float, String, Interger, Boolean, Date, Date & Time)
Display format: định dạng dữ liệu
Current value: giá trị hiển thị mặc định cho parameter
Value when workbooks opens: giá trị hiển thị khi mở workbook
Allowable values: các giá trị đưa vào parameter (all – tất cả, list – danh sách, range – khoảng dữ liệu)

2. Types of Parameters

2.1 Calculate duration between two dates

Bước 1: Tạo parameter
Step 1: Create parameter

• Data type: String
• Allowable values: List
• Value & Display As: day, month, year – Fixed
• Current value: day
• Value when workbook opens: Current value

Các giá trị trong danh sách gồm có: day, month, year – các biến này sẽ được sử dụng trong hàm DATEDIFF để tính khoảng thời gian giữa hai thời điểm.
All values in this list includes: day, month, year – these constants will be used as elements in DATADIFF functions to calculate the duration between two dates.

Tại Display As, bạn có thể thay đổi tên hiển thị của các giá trị bên cột Value
At Display As column, users can change the display text of corresponding values in Value column.

Bước 2: Tạo phép tính với hàm DATEDIFF
Step 2: Create calculated field using DATEDIFF function

Bạn đọc xem cấu trúc và cách sử dụng hàm DATEDIFF tại đây.
More detailed information about DATEDIFF function at here.

2.2 Switch Dashboard from Revenue to Profit

Bước 1: Tạo parameter
Step 1: Create parameter

• Data type: String
• Allowable values: List
• Value & Display As: Revenue, Profit – Fixed
• Current value: Revenue
• Value when workbook opens: Current value

Bước 2: Tạo phép tính sử dụng hàm IF
Step 2: Create calculated file using IF function

Phép tính này sử dụng hàm điều kiện IF để sử dụng cột Sale nếu Parameter trả về Revenue hoặc trả về cột Profit nếu Parameter trả về Profit.
This calculated field uses IF function to return Sale column if Parameter shows Revenue otherwise return Profit column.

Kể từ bây giờ, chúng ta sẽ sử dụng measure =#Revenue_Profit thay cho #Sales và #Profit. Dấu bằng (=) là biểu tưởng của phép tính được tạo thủ công bởi người dùng.
From now on, we use =#Revenue_Profit measure instead of #Sales and #Profit measures. Equal sign symbolizes manually calculated field.

Bước 3: Tạo dashboard và hiển thị parameter
Step 3: Create a dashboard and show the parameter

Còn cập nhật…
Updating…

Leave a comment