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 14, 2018 in Tableau by Naruto
• 710 points
4,264 views

1 answer to this question.

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
• 860 points

Related Questions In Tableau

0 votes
1 answer

sum wrt previous outstanding amount and month current amount

Hi Keerthi, I used a similar data to ...READ MORE

answered Jun 6, 2019 in Tableau by Cherukuri
• 33,030 points
900 views
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 12, 2018 in Tableau by QueenBee
• 1,820 points
1,086 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 12, 2018 in Tableau by xyz
• 1,560 points
7,055 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
882 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
478 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
• 860 points
2,068 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 15, 2018 in Tableau by AwesomeSauce
• 860 points
1,672 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
• 860 points
3,855 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP