Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
musketeers
Creator
Creator

how to compare date column for last two years date

Hi,

I need to create a line chart to display sum of sales for last two years. I have a date column for the x axis dimension. I am using the below if condition to get last two year dates. but this is not working.

=if( MonthName(Date_Column>= Monthname(addmonths (today(),-12))), MonthName(Date_Column))

I am using Monthname function here to get the months names with year value like Jun 2011, Jul 2011 and so on.

Kindly help me in this issue as I am trying to get the dates for last two year from todays date from the given date column.

Thanks

Rajneesh

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

     if(DATE_COLUMN>=Addmonths(Today(),-12),Monthname(DATE_COLUMN))

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

     if(DATE_COLUMN>=Addmonths(Today(),-12),Monthname(DATE_COLUMN))

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
musketeers
Creator
Creator
Author

Hi Kaushik,

Thanks for your reply. Ohh this is working.

And also in my expression I have just found that there is a bracket in wrong place so I was not getting desired output.

The modified expression I have used is as below

=if( MonthName(DATE_COLUMN) >= Monthname(addmonths (today(),-12)), MonthName(DATE_COLUMN))