Free Tableau Calculations and Parameters Questions and Answers 1 — Questions and Answers
Question 1: An analyst needs to create a calculation that shows the average sales for each customer, regardless of what other dimensions (like Region or Product Category) are shown in the visualization. The value should remain fixed for each customer. Which type of calculation should be used to achieve this?
- A Table Calculation
- A basic aggregation like AVG([Sales])
- A FIXED Level of Detail (LOD) expression (Correct answer)
- An INCLUDE Level of Detail (LOD) expression
Correct answer: A FIXED Level of Detail (LOD) expression
A FIXED Level of Detail (LOD) expression computes a value using the specified dimensions without reference to the dimensions in the view. In this scenario, `{ FIXED [Customer Name] : AVG([Sales]) }` would calculate the average sales for each customer across the entire dataset, and this value will not change when other dimensions are added to or removed from the visualization.
Question 2: A dashboard creator wants to allow users to dynamically change the date part for a DATEDIFF calculation (e.g., switch between seeing the difference in days, months, or years) without editing the worksheet. Which Tableau feature is best suited for this requirement?
- A calculated field with a CASE statement
- A quick filter
- A set
- A parameter (Correct answer)
Correct answer: A parameter
A parameter is a workbook variable that can replace a constant value in a calculation. By creating a string parameter with values like 'day', 'month', and 'year', the user can select a value, and this parameter can be used directly in the `DATEDIFF` function's `date_part` argument (e.g., `DATEDIFF([Date Parameter], [Start Date], [End Date])`). This makes the calculation dynamic and user-driven.
Question 3: You are analyzing sales performance and want to calculate the difference in sales between the current month and the previous month for each product. Which of the following is the most appropriate type of calculation to use?
- Level of Detail (LOD) Expression
- Table Calculation (Correct answer)
- Basic Expression
- Parameter Control
Correct answer: Table Calculation
Table calculations operate on the aggregated data present in the visualization. Functions like `LOOKUP()` or quick table calculations such as 'Difference From' are designed to compute values based on other rows in the view, which is perfect for comparing a value in the current row (current month's sales) with a value in a previous row (previous month's sales).
Question 4: An analyst is creating a calculated field to determine the number of days between a customer's `[Order Date]` and the `[Ship Date]`. The correct syntax for this calculation is `DATEDIFF('day', [Order Date], [Ship Date])`. What will be the result if a specific order's `[Ship Date]` is earlier than its `[Order Date]`?
- A positive integer
- A negative integer (Correct answer)
- A NULL value
- A #ERROR message
Correct answer: A negative integer
The `DATEDIFF` function subtracts the start date (the second argument) from the end date (the third argument). If the `start_date` (`[Order Date]`) is after the `end_date` (`[Ship Date]`), the resulting difference will be a negative number.
Question 5: Which of the following describes a key difference between a Tableau Parameter and a Filter?
- Filters are always single-select, while Parameters can be multi-select.
- Parameters can be used across multiple, different data sources, while a standard filter is tied to a single data source. (Correct answer)
- Parameters directly remove data from the view, while Filters require a calculated field to affect the data.
- Filters can accept any data type, while Parameters are limited to strings.
Correct answer: Parameters can be used across multiple, different data sources, while a standard filter is tied to a single data source.
Parameters are workbook-level variables and are not tied to any specific data source. This allows them to be used in calculations that can apply to sheets using different data sources. In contrast, a standard dimension or measure filter is created from a field within a specific data source and can only be applied to worksheets that use that same data source.
Question 6: A view shows SUM(Sales) by Region and State. The analyst wants to create a calculation that computes the total sales for each Region, effectively ignoring the State dimension that is present in the view. Which LOD expression would accomplish this?
- INCLUDE [Region] : SUM([Sales])
- FIXED [State] : SUM([Sales])
- EXCLUDE [State] : SUM([Sales]) (Correct answer)
- FIXED [Region], [State] : SUM([Sales])
Correct answer: EXCLUDE [State] : SUM([Sales])
EXCLUDE Level of Detail (LOD) expressions compute aggregations that are less granular than the view by removing specified dimensions from the calculation context. In this case, `EXCLUDE [State] : SUM([Sales])` tells Tableau to sum the sales at a level of detail that excludes the 'State' dimension, resulting in the total sales for each Region.
An analyst needs to create a calculation that shows the average sales for each customer, regardless of what other dimensions (like Region or Product Category) are shown in the visualization.
The value should remain fixed for each customer.
Which type of calculation should be used to achieve this?