3 Replies Latest reply on Aug 28, 2016 6:23 PM by Trần Ngọc Sơn

# How to sum Sales with conditional Order Date < Date( create by paramter)

Hi all,

I caclculate sum Sales for 3 month that Date create by parameter.

I have 2 parameter ( parameter Year, parameter Month with data type is Interger), i create calculation to convert parameter to date:

Sales condition:

if attr([Order Date])>= [Date start]

and attr([Order Date])<= [Date end]

then sum([Sales]) END

The calculation Sales condition don't wrong but it's Null,

How to sum Sales with period time create by parameter?

I attach file workbook i do. But it's wrong.

• ###### 1. Re: How to sum Sales with conditional Order Date < Date( create by paramter)

Hey Tran,

Write your Sales Condition calculation like this:

if [Order Date]>= [Date start]

and [Order Date]<= [Date end]

then [Sales] END

You originally specified a SUM([Sales]) in your calculation but this is not necessary since it's automatically a SUM when you use the measure.

Hope this helps!

Regards,

Matthias

• ###### 2. Re: How to sum Sales with conditional Order Date < Date( create by paramter)

Matthias is on point! ATTR and SUM are aggregation functions in Tableau, that means they will get a result out of a combination of rows. In your case, you want to limit the rows before they get aggregated (i.e. only look at the transactions between the Start and End Dates, then get the SUM of Sales). This is what Matthias wrote, a row-level formula, which returns one result for every row.

• ###### 3. Re: How to sum Sales with conditional Order Date < Date( create by paramter)

Thanks for support. I have to sum(sales) because I blending 2 data source, calculation Sum(Measure). So that I don't know how to sum Sales with conditional Order Date < Date( create by paramter)