How to create a new dimension in Tableau which will incorporate only some selected values of the original dimension? Should I use the IF Contains statement to isolate some attributes from a dimension?
- Tableau FAQs
- December 11, 2018
To create a new dimension in Tableau, you can use an IF expression with any other function. For example, in the previous question, a case was considered where IF was used in conjunction with CONTAINS and STARTWITH, but you can also use other functions. Next, using an example, we will look at what other functions you can use IF and how it works.
The first use case is to select numeric values from a selected field. So, for example, we can use conditional operators to display only the values we need in a new dimension:
IF [ProductIDGroup]='Other' THEN [OrderQty] ELSE NULL END
IF [ProductIDGroup]=’Other’ – in this expression, we are filtering only the ProductGroup value equal to “Other.”
THEN [OrderQty] – if the previous condition is TRUE, then we print OrderQty. You can display any other field, for example, ProductID.
ELSE NULL END – if the condition is FALSE, then we output NULL and end the expression using the END function