KNOWLEDGE BASE

How to Get the Count of the Year Ranked in the Top N Sales for Each State and Display It in a Choropleth Map


Published: 04 Aug 2023
Last Modified Date: 07 Aug 2023

Question

How to get the count of the year ranked in the top N sales for each state and display it in a choropleth map.

 

Environment

  • Tableau Desktop 

Answer

Below is an example using Sample-Superstore data.
User-added image

1. Create a parameter as follows;
 User-added image
2. Right-click Sales Top N parameter and select Show Parameter.
3. Create a calculated field and name it Included in Sales Top N ?.
IF RANK(SUM([Sales])) <= [Sales Top N] THEN 1 ELSE 0 END
4. Create a calculated field and name it Count of Sales Top N.
WINDOW_SUM([Included in Sales Top N ?])
5. Add Longitude (generated) to Columns.
6. Add Latitude (generated) to Rows.
7. Add Country/Region, State/Province and YEAR(Order Date) to Detail.
8. Add Count of Sales Top N to Color.
9. Right-click Count of Sales Top N in Color and select Edit Table Calculation.
10. Configure table calculation as follows;
 User-added image User-added image
11. Right-click Count of Sales Top N in Color and select Discrete.
12. Change color as you like.
Did this article resolve the issue?