4 Replies Latest reply: Jul 19, 2016 6:26 AM by Sunny Talwar

# Finding difference

Hi,

Can someone tell me a way to calculate the difference between two different months that are selected?

I know the way to find and aggregation between two different months but it's hard for me to find a difference.

fx --> GetFieldSelections([ORDER_DT.autoCalendar.Month], ',', 2)

Thank you

• ###### Re: Finding difference

Hi June, maybe looking for the difference between max and min:

Max(DateField)-Min(DateField) --> Would return the difference in days

Or: Month(Max(DateField)) - Month(Min(DateField))

Or: Max([ORDER_DT.autoCalendar.Month]) - Min([ORDER_DT.autoCalendar.Month])

• ###### Re: Finding difference

but I'm actually looking for the difference between SalePrice of two different months.

Thank you

• ###### Re: Finding difference

Hi, then you can use set analisys to filter, in example, using a numeric YearMonth field:

Sum({<YearMonth={'\$(=Max(YearMonthField))'}>} Sales)-Sum({<YearMonth={'\$(=Min(YearMonthField))'}>} Sales)

• ###### Re: Finding difference

Or this:

FirstSortedValue(Aggr(Sum(Sales), [ORDER_DT.autoCalendar.Month]), -Aggr([ORDER_DT.autoCalendar.Month], [ORDER_DT.autoCalendar.Month])) - FirstSortedValue(Aggr(Sum(Sales), [ORDER_DT.autoCalendar.Month]), Aggr([ORDER_DT.autoCalendar.Month], [ORDER_DT.autoCalendar.Month]))