Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
yelin_nyu
Creator
Creator

set analysis of 2 months ago

I want to compare qty of today, and that of 2 months ago.

dimension: item, location, month

Used set analysis: sum({$<Month={'$(=AddMonths(Month,-2))'}>}[Total Qty])

not working. did I do something wrong?

8 Replies
MK_QSL
MVP
MVP

Try This if your Month Dimension is like 'Jan', 'Feb' etc

=SUM({$<Month = {'$(=Month(Today())-2)'}>}[Total QTY])

MK_QSL
MVP
MVP

Or try this if Month is in Numeric Form

=SUM({$<Month = {'$(=month(AddMonths(now(0), -2)))'}>}[Total QTY])

yelin_nyu
Creator
Creator
Author

How do I do a rolling 2 months? In Dec, I want to see that of Oct, in Nov, I want to see Sep

Nicole-Smith

yelin_nyu
Creator
Creator
Author

didn't work for me.

say april is 10, may is 15, jun is 20.

I want to use jun/april. july/may, aug/jun....

whiteline
Master II
Master II

Hi.

You can't roll with set analysis, because the set is calculated once for all dimension values.

As you include month as dimension, you can try to use inter-record functions like above/before. Though this approach has some issues if months are not continuous.

Another way is to calculate the sums for 2 moths ago in script.

MK_QSL
MVP
MVP

You can write below code in script to get the two month before data.

Month(AddMonths(TempDate,-2))as Month2,

Now Use Month2 List BOX and below CODE...

=SUM([Total QTY])

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this, if you have date field in your data model, use separate expressions for each 2 months like this

For Dec-2013

set vMaxDate = MakeDate(2013, 12);

For Oct-2013 & Nov-2013

=Sum({$<Month=, Year=, Quarter=, DateDimensionName={'>=$(=MonthStart(vMaxDate, -2))<=$(=MonthEnd(vMaxDate, -1))'}>}[Total Qty])


For Aug-2013 & Sep-2013

=Sum({$<Month=, Year=, Quarter=, DateDimensionName={'>=$(=MonthStart(vMaxDate, -4))<=$(=MonthEnd(vMaxDate, -3))'}>}[Total Qty])


For Jun-2013 & Jul-2013

=Sum({$<Month=, Year=, Quarter=, DateDimensionName={'>=$(=MonthStart(vMaxDate, -6))<=$(=MonthEnd(vMaxDate, -5))'}>}[Total Qty])


Regards,

Jagan.