Loading

Sort Records Based on This Year's and Previous Year's Sales

게시 일자: Apr 23, 2026
과업

How to sort records based on this year's and previous year's sales.

If you want to sort the records based on this year's sales, or if there are no sales this year, based on the previous year's sales.

Current behavior
User-added image
Desired behavior

User-added image

단계
1. Connect to attached data source 'deta.xlsx' from Tableau Desktop.
2. Drag Date to Columns and Company to Rows.
3. Drag Sales to the view as show below.
User-added image
4. Create a new calculated field as follows:
     Name : Previous Year Sales
     Calculation : {FIXED [Company]:SUM( 
                           IF DATEPART('year', [Date]) = YEAR(TODAY()) - 1
                           THEN [Sales] END)}
5. Create a new calculated field as follows:
     Name : This Year Sales
     Calculation : {FIXED [Company]:SUM( 
                           IF DATEPART('year', [Date]) = YEAR(TODAY())
                           THEN [Sales] END)}
6. Create a new calculated field as follows:
     Name : Sort by Sales
     Calculation : IF [This Year Sales] >= 1
                           THEN [This Year Sales] * 1000000000000
                           ELSE  [Previous Year Sales]
                           END
7. Right-click on Company on Rows and select Sort.
User-added image
8. Set the sort as follows:
User-added image
 
Knowledge 기사 번호

001458544

첨부 파일

deta.xlsx

8 KB

Book1.twbx

18 KB

 
로드 중
Salesforce Help | Article