Calculated Field Practice Questions
Calculated Field Practice Questions
Calculated Field Practice Questions
Q1.Display ‘sales’ field values upto the nearest integer or to a specified two decimal places.
Ans.
To make the “sales” field value upto the nearest integer or to a specified two decimal places.
We can Simply just right click the ‘Sales’ field and choose format and change it to custom as
shown in the given Screenshot
Q2.How to create a column Alias?
Ans.
To create a column alias we just need to right the particular column we need make alias
for, then go to alias and change the aliases default name to whatever we want them to be. For
eg. in the screenshot below I changed the name for supplies to other.
Q3.How to get current date and time?
Ans. We can get current date and time by using a calculated function named Now which
returns value of current date and time in a calculated field. I have used this calculated
field in the title as in the Screenshot below:-
Here these shapes represent different data types and for date type it’s the Calendar one.
Or we can go to data source to and click on the above symbols to find out the data type.
Q5.Give an expression to add 4 months to the date 014-03-12?
Q6.Use a CASE function to display the following information: When the value “Paris” is
found, it uses “PS.” When “United Kingdom” is found, it uses “UK.” All other values
receive the value “World.”
Ans.
Expression:- Case [Region] WHEN “Paris” THEN “PS” WHEN “United Kingdom”
THEN “UK” ELSE “World” END
Ans.
Expression:- IF [Region]== “Paris” THEN “PS” ELSEIF [Region]== “United Kingdom”
THEN “UK” ELSE “World”
Ans. Count(Expression)
Expression:- Count(Cities)
Output:- Will return no. of cities in cities group.
Q10. Which filter is used to get the top 10 values from a view?
Ans. Top option in Tableau filter is used to limit the result set from a filter. As for the
question you want only the top 10 values. You can apply this filter using the inbuilt options
for limiting the records in many ways or by creating a formula.
Ans. We can find the position by using FIND(“String”, “Sub-String”, [Index]) function
Expression:-
FIND(“SOFTWARE”, “T”)
Output:- 4
Q13. Use string functions to converts all characters in the ‘MISSISSIPPI’ string into lower
case letters.
Ans. We can lower all the letters by using LOWER(string)
Expression:- LOWER(“MISSISSIPPI”)
OutPut:- mississippi
Q17. Find out the sales in the cities, which contain the letter “o”?
Ans. For this, We can simply make a calculated field using CONTAINS(field, string)
function
Expression:-CONTAINS([cities], “o”)
Q18. Find out the total sales along with the difference in the date of sales in months from
12st Feb 2009.
Ans.
Q19. Return ‘Good’ if the Profit is greater than 0, and Quantity is greater than 25000,
otherwise, return Bad.
Ans. We will make a calculated field as “GoodBad” with the
Expression:- IF [Profit]>0 AND [Quantity]>25000 THEN "Good" ELSE "Bad" END
Output:
Q20. Return ‘Good’ if the Profit is greater than 0, or Quantity is greater than 25000,
otherwise, return Bad.
Ans. Same as Above.
Q21. Use Tableau IIF function to returns true if Profit is greater then zero. Otherwise, Loss
will return.
Ans. For this we will make a new calculated field Named “True Loss”
Expression:-
Output:-
Q22. Check if there is nulls in quantity field.
Ans. To check for null values in quantity field we just have to make a calculated field
using ISNULL function with
Expression:-IF ISNULL([Quantity]) THEN “Null”
Q23. Replace null values with zero value if there is nulls in quantity field.
Q24. Replace null values with 10 if there is nulls in quantity field.
Q25. Recode Categories Furniture , Office Supplies and Technology as Category 1,
Category 2 and Category 3 respectively.
Q26. Find the subcategories that are selling above average and the one below average.
Q27. Find the difference in months from order date to ship date.
Q28. Add 2 months in orderdate.
Q29. Name the order days in the March 2011