Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

4 Replies
rubenmarin

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

Not applicable
Author

Thanks for the reply,

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

Thank you

rubenmarin

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)

sunny_talwar

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