KNOWLEDGE BASE

Sorting Monthly Values by the Values for the Current Month and Current Year


Published: 12 Jun 2020
Last Modified Date: 19 Jun 2020

Question

Sorting Monthly Values by the Values for the Current Month. Example: Sorting monthly sales value for category by current month and year sales  
User-added image

Environment

  • Tableau Desktop

Answer

1. Create a view with your date dimension and measure value(Example: Sales)

2. Create a calculated field Sort calc like below:

if  YEAR([Order Date]) = YEAR(today()) and MONTH([Order Date]) = MONTH(today()) 
then ([Sales]) end

3. Right click on dimension in rows -> Sort -> Sort by field -> choose Sort calc as the field in descending order

The final result looks like below with all sales values sorted by current month sales i.e. June :
User-added image
Did this article resolve the issue?