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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
jclabeau
Contributor
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
Partner - Specialist
Partner - Specialist

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
Specialist II
Specialist II

Share a sample piece of data if possible.

Your variables seems fine