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 3,841 views

## 1 answer to this question.

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))

• 860 points

## sum wrt previous outstanding amount and month current amount

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

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

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

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

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

## How to determine average per event by year?

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

## Calculating count average from averages

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

## How to return the value on which the condition is met for the first time?

It looks like you are trying to ...READ MORE

## How to Split a Measure in Tableau?

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