Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
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
MVP
MVP

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

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

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