Skip to main content

I am trying to create a top customer report but I am facing an issue I wanted to sort the customer’s name in descending order on latest year which is 2013.

There is field called Order Date it has three years of data 2010, 2011, 2012, and 2013 I wanted to sort my customers on descending order based on the year 2013. But I also want to see other years also.

I feel that I was unable explain the question properly. So I am attaching the workbook can anyone please help me out with this question.

 

Thank You

Nani

20 answers
  1. Jan 25, 2015, 9:57 PM

    Nani

     

    Here's how I would approach a solution, based on my understanding of your requirements - to summarise:

    • You have a single column for Order Date, the contents of which span several years
    • You would like to see sales by year for each customer, in a bar chart, with the bars sorted in descending order by year (i.e. most recent year at the top)
    • You would like to sort the customers by their sales in the most recent year (2013), in descending order 

    So, based on these needs, I suggest:

    1. Create a calculated field: Order Year = year([Order Date]) 

    2. Create a calculated field: Sort Value = if [Order Year] = 2013 then [Sales] end 

      This will put the Sales value in the Sort Value field only if the Order Year is the one you want - otherwise Sort Value will be null; this allows you to sum the Sort Value field to determine just 2013 sales. 

    3. Create your bar chart with:
      • Rows shelf: Customer Name, Order Year
      • Columns shelf: SUM(Sales) 

         

    4. Sort Order Year in descending order 

       

    5. Sort Customer Name by the Sort value field (descending) 

       

    6. Finally, drag Order Year onto the Color shelf to achieve a similar result to your Excel image. 

       

     

    You could extend by using a parameter to determine the year to sort by:

    1. Add a parameter Order by Year
    2. Load its values from Order Year
    3. Modify the Sort Value calculation to reference your Order by Year parameter value 

    4. Display a parameter control to allow the user to choose which year's sales to sort by 

    The attached workbook shows this approach, including the user-specified parameter, using the sample Superstore data that shps with Tableau, but t should be easy to replicate this in your data.

0/9000