Sum of previous two months sales where the current month is entered by the user.

0 votes
I've a scenario, I need to calculate sum of sales of previous 2 months if I select any month. That is, my months are in parameter and if I select any month I should be able to sum previous 2 months sales. Can anyone help me to achieve this end result?
Aug 13, 2018 in Tableau by Naruto
• 710 points
28 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

It can be achieved easily by creating a calculated field, here is how it goes:

  1. Create a Parameter "Month_Paramater"
  2. Choose Integer --> list
  3. add list of values (e.g. 1 as January, 2 as February ..... so on till 12 as December)

  4. Create a calculated field :

  5. Use calculation:

    SUM(IIF(DATE_PART('month', [Order Date]) = [Month_Paramater] - 1 OR DATE_PART('month', [Order Date]) = [Month_Paramater] - 2, [Sales], 0))

answered Aug 14, 2018 by AwesomeSauce
• 830 points

Related Questions In Tableau

0 votes
1 answer

Divide count of Table 1 by count of Table 2 on the same time interval

Use a custom SQL to create a ...READ MORE

answered Apr 11, 2018 in Tableau by QueenBee
• 1,810 points
13 views
0 votes
1 answer
0 votes
1 answer

How can I calculate the median of sales price using 3 variables in Tableau

First let me clarify things for you. ...READ MORE

answered Apr 11, 2018 in Tableau by xyz
• 1,550 points
270 views
0 votes
1 answer

Is it possible to apply filter just to one of the measures

Hey @Ghost, Why don't you use Level of Detail ...READ MORE

answered Apr 17, 2018 in Tableau by Atul
• 10,200 points
17 views
0 votes
1 answer

How to determine average per event by year?

Hi Roshan, Create a new calculated field (use ...READ MORE

answered Sep 25, 2018 in Tableau by Machdata
• 340 points
40 views
0 votes
0 answers

Calculating count average from averages

I've a calculated field in Tableau which ...READ MORE

May 28, 2018 in Tableau by Mahima Choudhary
15 views
0 votes
1 answer
0 votes
1 answer

How to Split a Measure in Tableau?

Have you tried using an IF statement: IF ...READ MORE

answered Aug 14, 2018 in Tableau by AwesomeSauce
• 830 points
46 views
0 votes
1 answer

How to display days data based on date selected in the filter by the user.

You can create a parameter for dates. Select data ...READ MORE

answered Aug 14, 2018 in Tableau by AwesomeSauce
• 830 points
28 views
0 votes
1 answer

Want to hide the Bar for Grand Total in the bar chart in Tableau

Tableau treats the whole visualization uniformly.  If you ...READ MORE

answered Aug 10, 2018 in Tableau by AwesomeSauce
• 830 points
260 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.