知识库

How to calculate the measure of a field that contains a specific string and other fields


发布时间: 21 Feb 2023
上次修改日期: 22 Feb 2023

问题

How to calculate the measure of a field that contains a specific string and other fields.

For example, if you enter "Book", sales in the subcategory containing the string "Book" will be displayed, as well as sales in all other subcategories.
 

环境

  • Tableau Desktop

答案

1. Connect to Sample Superstore data source.
2. Create a new parameter like the following.
User-added image
3. Right click on [Enter Sub Category Name] -> Show Parameter
4. Create a new calculated field as following.
     Name : Sales of Specific Sub Category and the others
     Calculation : IF CONTAINS([Sub-Category],[Enter Sub Category Name]) = TRUE
                          THEN [Sub-Category]
                          ELSE "Others"
                          END
5. Drag [Sales of Specific Sub Category and the others] to Rows.
6. Drag [Sales] to Text on Marks.
User-added image
此文章是否已解决问题?