Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
danielnevitt
Creator
Creator

Variables

Hi,

I am looking to use variables to restrict data shown in straight tables, pivot tables and bar graphs.

Currently I set the following:

vCurrentMonth=MonthName(today())

vCurrentMonthLess1=vCurrentMonth-1

vCurrentMonthLess2=vCurrentMonth-2

I then set the document properties number format to Date MMM YYYY

This produces the following data:

vCurrentMonth = Dec 2013

vCurrentMonthLess1 = Nov 2013

vCurrentMonthLess2 = Nov 2013 (Not sure why this doesn't return Oct 2013)

Also when I try to use the vCurrentMonthLess1 as a variable in the straight table it returns a number 41608 rather than Nov 2013.

Does anyone have any idea what I am doing wrong?

Thanks for your help.

Regards,

Daniel

2 Replies
Gysbert_Wassenaar

If you look up the Monthname function in the help file you will see that it returns a date as underlying value. The month name is merely the display format. Monthname(today()) returns the date december 1st. If you subtract 1 from that you get november 30. If you subtract another day from that you get november 29. What you can do instead is use addmonths(vCurrentMonth, -1) and addmonths(vCurrentMonth, -2)


talk is cheap, supply exceeds demand
marthacano01
Partner - Creator
Partner - Creator

Try this:

vCurrentMonth=MonthName(today()) 

vCurrentMonthLess1=MonthName(today(),-1)

vCurrentMonthLess2=MonthName(today(),-2)