Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

jclabeau
New Contributor

Problem with "AddMonths" , and displaying results for the previous month

Hi!...

Newbie question here. I am very excited to finally work with Qlik...but the syntax is a bit of a mystery...

I have been through the forums back and forth and tried so many combinations of this already...

I am using the latest version of Qlik Sense server.

I am trying to display the number of accounts for specific periods

My date filed is: "System_Date"

I have 2 variables: the last month , and the previous month

   Set vMax_System_Date = Max(System_Date) ;

   Set vMax_System_Date_minus_1 = AddMonths(Max(System_Date),-1,1) ;

They both work when I display the results in a KPI

The following formula works and gives me the count for the last month:

   =count(   { $< System_Date = {'$(=$(vMax_System_Date))'}  >} Account_ID )

If I substitute the variable for the previous month variable, it does not work:

   =count(   { $< System_Date = {'$(=$(vMax_System_Date_minus_1))'}  >} Account_ID )

Anybody knows what to do, and more importantly...why?

Many thanks in advance!

JC

2 Replies
avkeep01
Valued Contributor

Re: Problem with "AddMonths" , and displaying results for the previous month

Hi JC Labeau,

maybe you should remove the extra 1 in addmonths and add a corresponding date format. So if System_Date is formatted as YYYY/MM/DD then use the following variable setup.

Set vMax_System_Date_minus_1 = DATE(AddMonths(Max(System_Date),-1) ,'YYYY/MM/DD' );

techvarun
Valued Contributor II

Re: Problem with "AddMonths" , and displaying results for the previous month

Share a sample piece of data if possible.

Your variables seems fine