Tableau: Calculated Fields

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

When creating a calculated field to determine GDP per capita, which calculation accurately represents the relationship between GDP and Population?

  • SUM([GDP]) + SUM([Population])
  • SUM([Population]) / SUM([GDP])
  • SUM([GDP]) / SUM([Population]) (correct)
  • SUM([GDP]) * SUM([Population])

You have a 'Sales' field and a 'Profit' field. You want to determine 'Net Cost'. Which calculation would you use when creating a calculated field?

  • [Profit] - [Sales]
  • [Sales] - [Profit] (correct)
  • [Sales] + [Profit]
  • [Sales] * [Profit]

Which of the following actions can be performed on a string field using calculated fields?

  • Trimming extra spaces
  • Changing capitalization
  • Replacing inconsistent values
  • All of the above (correct)

You're combining a string field (Customer Name) and an integer field (Customer ID). What type of calculation do you need to perform?

<p>Data Type Conversion (C)</p>
Signup and view all the answers

You want to find the ratio of total profits divided by the total sales. What should you do?

<p>Calculate the sum of profits and the sum of sales separately, then divide the aggregated profit by the aggregated sales in a calculated field. (B)</p>
Signup and view all the answers

Which of the following is NOT a component of a calculation (formula) in Tableau?

<p>Visualizations (B)</p>
Signup and view all the answers

In Tableau calculations, how are fields typically represented?

<p>Enclosed in square brackets (C)</p>
Signup and view all the answers

When are aggregation functions like SUM, AVG, and COUNT available for use in a calculated field?

<p>When the fields being used are numeric. (B)</p>
Signup and view all the answers

In a Tableau calculation, what is the purpose of 'Parameters'?

<p>To replace constant values in the calculation. (A)</p>
Signup and view all the answers

What is the purpose of adding 'Comments' in calculated fields?

<p>To provide context for the calculation. (A)</p>
Signup and view all the answers

In Tableau, what is the key difference between clicking 'Apply' and 'OK' when creating a calculated field?

<p>'Apply' previews the calculation results, while 'OK' saves the calculation. (B)</p>
Signup and view all the answers

In Tableau, which function is used to extract a specific number of characters from the left side of a string?

<p>LEFT() (D)</p>
Signup and view all the answers

What will LEFT([Postal Code], 2) return if the postal code is "98103"?

<p>&quot;98&quot; (D)</p>
Signup and view all the answers

Which function is used to divide a string into substrings based on a specified delimiter?

<p>SPLIT() (B)</p>
Signup and view all the answers

What result will SPLIT([Phone], “-”, 2) produce if the [Phone] field contains "206-633-3400"?

<p>633 (D)</p>
Signup and view all the answers

Which function checks if a string contains a specified substring?

<p>CONTAINS() (D)</p>
Signup and view all the answers

What is the purpose of the REPLACE() function in Tableau?

<p>To substitute a substring with another substring. (C)</p>
Signup and view all the answers

Which functions can be used to change the capitalization of a string field in Tableau?

<p>UPPER() and LOWER() (D)</p>
Signup and view all the answers

Which function removes leading and trailing spaces from a string?

<p>TRIM() (B)</p>
Signup and view all the answers

When using a date function in Tableau, how should the date_part argument be formatted?

<p>Singular, lowercase, enclosed in single quotes (e.g., ‘month’) (A)</p>
Signup and view all the answers

Which function returns a specific part of a given date as a number?

<p>DATEPART (A)</p>
Signup and view all the answers

Which function returns a specific part of a given date as a string?

<p>DATENAME (A)</p>
Signup and view all the answers

Which function is used to add a specified increment to a given date?

<p>DATEADD (B)</p>
Signup and view all the answers

You need to calculate the difference in days between an order date and a ship date. Which function should you use?

<p>DATEDIFF (D)</p>
Signup and view all the answers

Which function truncates a date to the level of the specified date part?

<p>DATETRUNC (A)</p>
Signup and view all the answers

You want a field that displays January 1, 2021, given that the original date is January 23, 2021. Which function can be used to derive this?

<p>DATETRUNC('month', #January 23, 2021#) (A)</p>
Signup and view all the answers

When calculating 'Time to Ship' using the DATEDIFF function, what should be the first argument?

<p>The date part to find the difference in (e.g., 'day'). (D)</p>
Signup and view all the answers

In Tableau, what is a Table Calculation?

<p>A secondary calculation performed on top of a returned result set. (A)</p>
Signup and view all the answers

Which of the following computations are pre-defined 'Quick Table Calculations' in Tableau?

<p>Running Total, Percent of Total, Year over Year Growth (B)</p>
Signup and view all the answers

After applying a Table Calculation in Tableau, how can you identify that a field has a table calculation applied?

<p>The delta symbol (Δ) appears on the pill. (C)</p>
Signup and view all the answers

What is a common issue with real-world datasets that can be addressed using calculated fields in Tableau?

<p>The presence of null values or blanks (A)</p>
Signup and view all the answers

Why is it important to convert nulls to zeros when comparing quotas and sales?

<p>You cannot compare a number to a null value. (C)</p>
Signup and view all the answers

Which function returns a zero wherever there is a null value?

<p>ZN() (A)</p>
Signup and view all the answers

What is the final step suggested to enhance the visualization of sales quotas and corrected quotas?

<p>Add corrected quota to the Tooltip. (D)</p>
Signup and view all the answers

How do you create a calculated field for cost, defined as sales minus profit?

<p>SUM([Sales]) - SUM([Profit]) (A)</p>
Signup and view all the answers

What is the main difference between Operators and Functions?

<p>Operators are shortcuts for complex functions. (A)</p>
Signup and view all the answers

When performing a date calculation using DATENAME, what data type does this function return?

<p>String (A)</p>
Signup and view all the answers

You're trying to determine a product's category based on its ID. The IDs are structured as [Category]-[Other Information]. For instance, TEC-1234 indicates the 'Technology' category. Which formula will accurately extract the category?

<p><code>SPLIT([Product ID], &quot;-&quot;, 1)</code> (A)</p>
Signup and view all the answers

If you have a dataset with missing sales quota values, what is the primary reason for converting these Null values to zero when comparing sales performance against quotas?

<p>To ensure that statistical calculations don't fail and comparisons are accurate. (B)</p>
Signup and view all the answers

You've used a table calculation in Tableau. How can you quickly identify a field that has a table calculation applied to it?

<p>The field's pill will display a delta symbol. (B)</p>
Signup and view all the answers

You are given a dataset with 'Product Names' that contain inconsistent use of ampersands ('&') instead of the word 'and'. What's the most efficient way to replace all instances of '&' with 'and' across the entire 'Product Name' field?

<p>Using the <code>REPLACE()</code> function within a calculated field to substitute '&amp;' with 'and'. (B)</p>
Signup and view all the answers

Flashcards

Calculated field use case?

Used to calculate GDP per capita by calculating a ratio of GDP and Population.

What does a calculation in Tableau include?

A calculation, also known as a formula, includes fields, functions, operators and parameters.

What do calculated fields bring in?

Calculated fields bring in existing fields in your data, including data source fields and any calculated fields you built previously.

What are functions?

Functions are operations you perform on your data, which vary depending on the data type, such as string, number, or date.

Signup and view all the flashcards

What are operators?

Operators are shortcuts for complex functions such as addition (+), subtraction (-), multiplication (*), division (/), comparisons (==,=,>,<,>=,<=,!=,<>).

Signup and view all the flashcards

What are parameters?.

Parameters are placeholder variables that can be inserted into calculations to replace constant values. Parameters are shown in purple and the parameter names are enclosed in square brackets.

Signup and view all the flashcards

What are comments?

Comments are custom annotations for your calculations inserted as a means of providing context for the user, but which do not appear in the view. Comments used in a calculation are shown in light gray and start with two forward slashes (//).

Signup and view all the flashcards

Difference between Apply and OK?

Clicking Apply allows you to preview how the calculation changes the data in the view. Clicking OK saves the calculation.

Signup and view all the flashcards

What is a Table Calculation?

This is a secondary calculation that is performed on top of a returned result set.

Signup and view all the flashcards

What does the DATEPART function do?

It returns part of a given date as a number.

Signup and view all the flashcards

What does the DATENAME function do?

It is similar to DATEPART, but it returns part of a given date as a string.

Signup and view all the flashcards

What does the DATEADD function do?

It returns a date in which the specified increment has been added to the given date.

Signup and view all the flashcards

What does the DATEDIFF function do?

It returns the difference between the two dates using the specified date part.

Signup and view all the flashcards

What does the DATETRUNC function do?

It truncates or “rounds down” the given date to the level of the specified date_part. This function returns a new date.

Signup and view all the flashcards

What do the LEFT and RIGHT string functions do?

Returns the leftmost or rightmost number of characters within a string.

Signup and view all the flashcards

What does the SPLIT string function do?

Returns a substring from a string, using a delimiter to divide the string into substrings and then using the token to determine which substring to return.

Signup and view all the flashcards

What does the CONTAINS string function do?

Returns true if the given string contains the specified substring; otherwise returns false.

Signup and view all the flashcards

What does the REPLACE string function do?

Searches string for substring and replaces it with replacement. If substring is not found, the string is not changed.

Signup and view all the flashcards

What do the UPPER and LOWER string functions do?

Updates the string to uppercase or lowercase characters.

Signup and view all the flashcards

What does the TRIM function do?

Returns the string with leading and trailing spaces removed.

Signup and view all the flashcards

What does the ZN function do?

The ZN function returns a zero wherever there is a null.

Signup and view all the flashcards

Study Notes

Calculated Fields in Tableau

  • Calculated fields are used in various scenarios like calculating GDP per capita.
  • The GDP per capita calculation involves dividing the sum of GDP by the sum of the population: SUM([GDP])/SUM([Population]).
  • Calculated fields enable creation of new fields from existing ones, like deriving net cost from Sales and Profit fields.
  • String values can be formatted using calculated fields to clean data by trimming spaces, changing capitalization, or replacing inconsistent values.
  • Calculations can change a field's data type to work with others, such as combining a string field (Customer Name) with an integer field (Customer ID).
  • Manipulation of date fields is possible, allowing for extraction of specific parts of a date or calculation of time between two dates.
  • It's possible to control how data is aggregated in a calculation, like calculating the ratio of total profits to total sales.
  • A calculation includes fields, functions, operators, and parameters: SUM([GDP]) / SUM([Population]) + [Parameter].
  • Fields in calculations are existing data fields and any previously built calculated fields, enclosed in square brackets and shown in orange (e.g., [GDP], [Population]).
  • Functions are operations performed on data depending on its type, such as aggregation functions (AVG, SUM, COUNT). Functions are blue and followed by parentheses.
  • Operators are shortcuts for complex functions (+, -, *, /, %, ==, >, <). They are dark gray. The first operator is /.
  • Parameters are placeholders for constant values, shown in purple and enclosed in square brackets.
  • Comments are annotations for calculations, displayed in light gray and starting with two forward slashes (//).
  • Clicking Apply allows you to preview how the calculation changes the data in the view, while clicking OK saves the calculation.
  • You can create a simple profit visualization by placing Profit to Columns, and Market and Subcategory to Rows, and filtering Category to just Furniture.
  • It is possible to have one distinct color for positive and negative numbers.
  • Calculated fields can be created by defining a formula via Analysis > Create Calculated Field.
  • The formula for positive/negative emphasis could be: IF SUM([Profit]) > 0 THEN "positive" ELSE "negative" END.
  • Name the calculated field "sign of profit" and add a comment in code with //.
  • An equal sign in front of the field indicates it’s a calculated field and not directly from the data source.

String Functions

  • LEFT(string, number) and RIGHT(string, number) return the leftmost or rightmost characters.
  • SPLIT(string, delimiter, token number) divides a string into substrings based on a delimiter.
  • CONTAINS(string, substring) returns true if a string contains a specified substring.
  • REPLACE(string, substring, replacement) finds a substring within a string and replaces it.
  • UPPER(string) and LOWER(string) convert a string to uppercase or lowercase.
  • TRIM(string) removes leading and trailing spaces.

Date Functions in Tableau

  • When using a date_part argument in a date function, it must be singular, all lowercase, and wrapped in single quotation marks (ex: 'month').
  • Relevant date functions:
  • DATEPART(date_part, date, [start_of_week]): Returns the specified part of a given date as a number. For example, DATEPART('month', #January 23, 2021#) = 1.
  • DATENAME(date_part, date, [start_of_week]): Similar to DATEPART but returns the date part as a string. For example, DATENAME('month', #January 23, 2021#) = January.
  • DATEADD(date_part, increment, date): Returns a date with a specified increment added. For example, DATEADD('day', 7, #January 23, 2021#) = January 30, 2021.
  • DATEDIFF(date_part, start_date, end_date, [start_of_week]): Returns the difference between two dates using the specified date part. For example, DATEDIFF('day', #January 23, 2021#, #February 24, 2021#) = 32.
  • DATETRUNC(date_part, date, [start_of_week]): Truncates a date to the level of the specified date_part. This function returns a new date. DATETRUNC('month', #January 23, 2021#) returns January 1, 2021.
  • To calculate the time it takes for an order to ship:
  • Create a calculated field named "Time to Ship.".
  • Use the DATEDIFF function: DATEDIFF('day', [Order Date], [Ship Date]).
  • Ensure the calculation is valid before clicking OK.

Introduction to Table Calculations

  • Table calculations are secondary calculations performed on a returned result set.
  • Tableau has pre-defined, commonly used computations called Quick Table Calculations that include: Running Total, Percent of Total, and Year over Year Growth.
  • Create a new sheet, put Category to Columns and Sales to Rows. Then move Order Date to Columns, expand to Quarters. Put Sales to Rows again
  • You can select the Running Total Quick Table Calculation from the dropdown men.
  • Can drag your Table Calc to the right axis for a dual axis chart then right click and synchronize the axis.
  • Table calculations are indicated by a delta symbol in the pill.

Data Validation - Nulls to Zeroes

  • Calculations can remove null values.
  • Convert nulls to zeros to be able to generate a comparison.
  • To convert nulls to zeros:
  • Right-click in the data window and select create calculated field.
  • Name it "Corrected Quota".
  • Use the ZN( function: ZN([Quota])
  • The ZN function returns zero wherever there is a null.
  • Visualizations need to be fixed by right clicking in the map and viewing the data.
  • Use SUM(Sales)-SUM(Corrected Quota) to view data in visualization.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Tableau Dashboard Design Principles Quiz
10 questions
Tableau 1.4: Les ions polyatomiques courants
6 questions
9 HVID SUM UP Tableau
20 questions
10 HVID SUM UP Tableau
15 questions
Use Quizgecko on...
Browser
Browser