KNOWLEDGE BASE

How to switch the display unit of a Crosstab using a parameter


Published: 07 Sep 2022
Last Modified Date: 08 Sep 2022

Question

How to switch the display unit of a crosstab with a parameter.

Example
User-added image

Environment

  • Tableau Desktop 

Answer

1. Connect to the Sample -Superstore data source.
2. Drag Category to Columns.
3. Create a new parameter as shown:
User-added image
4. Create a new calculation as follows:
    Name : Switch Unit
    Calculation : CASE [Select Unit]
                         WHEN 1 THEN ''
                         WHEN 1000 THEN "K"
                         END
5. Create a new calculation as follows:
    Name : Round Sales
    Calculation : ROUND(SUM([Sales])/[Select Unit],0) 
6. Create a new calculation as follows:
    Name : Setting Sales Unit
    Calculation : '$' +
                         STR( REGEXP_REPLACE(STR([Round Sales]),"(\d)(?=(\d{3})+$)","$0,"))
                         +  [Switch Unit]
7. Drag Setting Sales Unit to Text on the Marks card.
8. Right-click Select Unit > Show parameter.
 
Did this article resolve the issue?