KNOWLEDGE BASE

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


Pubblicato: 21 Feb 2023
Data dell'ultima modifica: 22 Feb 2023

Domanda

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.
 

Ambiente

  • Tableau Desktop

Risposta

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
Con questo articolo hai risolto il problema?