Published: 22 Jun 2022 Last Modified Date: 23 Jun 2022
Question
How to display sales totals for the past N days. For example, If N is 3 , the output results as follows.
Environment
Tableau Desktop
Answer
By following the steps below, Sales Totals will change dynamically depending on the value 'N' entered in the parameter.
<STEP 1 > -Preparation- 1. Connect to Sample Superstore. 2. While right-clicking drag [Order Date] to Rows > Select 'Order Date (Discrete)'. 3. Drag [Sales] to the cross tab.
<STEP 2 > -Calculate sales totals for the past N days- 4. Create a new parameter as following. 5. Right click on [Enter past days] > Show parameter 6. Create a new calculated field as following. Name : Sales Total Calculation : WINDOW_SUM((SUM([Sales])),-[Enter past days],0) 7. Drag [Sales Total] to the cross tab.
Thank you for providing your feedback on the effectiveness of the article.