KNOWLEDGE BASE

Unable to create a Map of Two Regions with Separate Color Gradients


Published: 04 Oct 2016
Last Modified Date: 12 Apr 2017

Issue

When adding measure to color, the option for gradient is not available for each option in measure color.

Environment

  • Tableau Desktop 10.0.1
  • Windows 7
  • Excel

Resolution

Step 1: Build the Original View

  1. Drag Longitude to Columns.
  2. Drag Latitude to Rows
  3. Drag Sales to Colors
  4. Drag Country and State to Details.
    1. Alternatively, you can change the Mark type to Filled Map
  5. Filter the view to only show 2 countries: United States and Canada

Step 2: Create a new calculated field for Canada

  1. Select Analysis > Create Calculated Field 
  2. In the Create Calculated Field dialog box, do the following and click OK:
  3. Name the field. In the example, this field is called "! Canada" and enter the following formula: 
    If [Country] = "Canada" then [Country] END

Step 1: Create a new calculated field for United States

  1. Select Analysis > Create Calculated Field 
  2. In the Create Calculated Field dialog box, do the following and click OK:
  3. Name the field. In the example, this field is called "! United States" and enter the following formula: 
    If [Country] = "United States" then [Country] END

Step 4: Change the Geographic Roles

On both newly created fields, change their geographic role to Country by right clicking each field and selecting Geographic Role > Country/Region.

Step 5: Continue building the view

  1. Drag a second copy of Latitude to the Rows shelf. 
    • Now, two Marks Cards are created
  2. In the Marks Cards labeled "Latitude", replace Country with one of the above calculated fields. 
  3. In the other Marks Card labeled "Longitude", replace Country with the other calculated field.
  4. Create a copy of "Sales" by right clicking and selecting Duplicate
  5. Drag one copy of the Sales field to color on the one of the Latitude Marks cards 
  6. Drag the other Sales field to color on the other Latitude Marks card.
  7. In the bottom right corner of the view, select Unknown and choose Filter data in the pop-up window.
    • This will assure that the Null values are not counted in the color gradient.
  8. Modify the color for one of the Country as necessary.
  9. Right-click the Latitude field to the right on the rows shelf and select Dual Axis
    • This will combine the two views into one.

Additional Information

To view these steps in action, see the video below: 
Did this article resolve the issue?