Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

gowtham174
New Contributor III

Previous Month Expression

Hi All,

can you please help me to populate previous month values, for the below sample set of data

data set

QtyMonth
101-01-2018
202-02-2018
303-03-2018
404-04-2018
505-05-2018
606-06-2018
707-07-2018
808-08-2018
909-09-2018
1010-10-2018
1111-11-2018
1212-12-2018

Thanks,

Gowtham

Tags (1)
14 Replies
isingh30
Contributor III

Re: Previous Month Expression

Put -1 after max month in your expression. You can use previous function as well.

Month minus previous month | Qlik Community

thiago_justen
Valued Contributor III

Re: Previous Month Expression

As Ishtdeep already said:

Num(Sum({<Month={"$(=Max(Month)-1)"}>}Qty))



Let's do this:

Sum({<Month={">=$(=MonthStart(AddMonths(Month,-1)))<=$(=MonthEnd(AddMonths(Month,-1)))"}>}Qty)

Thiago Justen Teixeira Gonçalves
WhatsApp: 24 98152-1675
Skype: justen.thiago
shiveshsingh
Valued Contributor III

Re: Previous Month Expression

Try this

F:

load *,Year(Date) as Year, Month(Date) as Month;

D:LOAD * INLINE [

   

    Qty, Date

    1, 01-01-2018

    2, 02-02-2018

    3, 03-03-2018

    4, 04-04-2018

    5, 05-05-2018

    6, 06-06-2018

    7, 07-07-2018

    8, 08-08-2018

    9, 09-09-2018

    10, 10-10-2018

    11, 11-11-2018

    12, 12-12-2018

];

Previous Month Expression

=sum({<Year = {"=max(Year)"}, Month={"$(=month(MonthStart(max(Date))-1))"}>}Qty)

gowtham174
New Contributor III

Re: Previous Month Expression

Hi Shivesh,

Can you please provide me in expression without editing the script.

Thanks,

Gowtham

gowtham174
New Contributor III

Re: Previous Month Expression

This expression showing 0 values

gowtham174
New Contributor III

Re: Previous Month Expression

i tried with but its not showing the result

Num(Sum({Month={"$(=Max(Month)-1)"}>}Qty))

arvind1494
Contributor III

Re: Previous Month Expression

Sum({Month={"$(=Max(Month),-1)"}>}Qty)


try this

gowtham174
New Contributor III

Re: Previous Month Expression

I tried with same but still not result

Sum({Month={"$(=Max(Month),-1)"}>}Qty)

arvind1494
Contributor III

Re: Previous Month Expression

sorry i made small mistake

use this:

Sum({Month={"$(=Max(Month,-1))"}>}Qty)