Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
NavinReddy
Creator II
Creator II

Set analysis

Hi All,

How to compare Current month Data and previous month Data

With one Expression

Could some one help me

Thanks In Advance

Niranjan

7 Replies
Anonymous
Not applicable

Hi,

You can use below expressions to compare current month and previous month data:

EXP1> sum({$<Month={$(=month(today()))}>}Value)

EXP 2> sum({$<Month={$(=month(addmonths(today(),-1)))}>}Value)

Regards

Nitin

salto
Specialist II
Specialist II

Hi,

two set analysis expressions, that will sum sales por this month and the previous month:

=sum({$<MonthNum={$(=max(MonthNum))}>} Sales)

=sum({$<MonthNum={$(=Max(MonthNum)-1)}>} Sales)

Hope this helps!

NavinReddy
Creator II
Creator II
Author

Hi,

Is not possible to write in one expression

Thanks,

Niranjan

Not applicable

hi,

Create these variables

vLastMonth=month(AddMonths(MakeDate(year,month,'01'),-1))

vLastYear= =max(year-1)

Then For Last Month Use:

=if(vLastMonth='Dec',sum({$<month={$(=vLastMonth)},year={$(=vLastYear)}>}stu_result.sales_qty),

sum({$<month={$(=vLastMonth)}>}stu_result.sales_qty)

)


For Current Month Use

=sum(stu_result.sales_qty)



User will need to select current year and month in this case.


Alternatively, you and also generate a calender, use it for selection and create variable and through set analysis calculate current and last year sales.


Regards,


Arun Goel

Not applicable

Of course if you want them under one expressions just subtract do a simple subscrtaction:

sum({$<month={$(=month(today()))}>}value)

-

sum({$<month={$(=month(addmonths(today(),-1)))}>}value)

salto
Specialist II
Specialist II

You can write it in an expression and check the % variance between one month and the previous one:

=sum({$<MonthNum={$(=max(MonthNum))}>} Sales)

/

sum({$<MonthNum={$(=Max(MonthNum)-1)}>} Sales)

and format the expression to show it in percentage.

Hope this helps.

Not applicable

If need one expression, load inline field:

Type:

LOAD * INLINE [

    Type

    Current

    Last

    ];

Then use this "Type" Field as dimension.

In expression use

=if(Type='Current',

"Expression for current Month",

if(Type='Last',

"Expression for LastMonth"

,''))