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: 
Not applicable

Limit dimension by date value

Hi, I have an input box where the user inputs a date in  MM/YYYY format.  I would like to put a line of set analysis in my dimension limit my graph to the input box date minus 12 months.  Any suggestions?  thanks, Jim

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Jim,

I usually don't download attachments, especialy of that size.

Judging by the response from Krishna, your requirement is not about the month one year prior to the "input box month", but 12 months prior.  If this is correct, Krishna's suggestion makes sense.  Except, the "Today()" in his expression should be replaced with the first date of the month which is in the input box.

Regards,

Michael

View solution in original post

13 Replies
Anonymous
Not applicable
Author

Input box means a variable.  Assuming, it has name vDateLimit.  Assuming also that your dimension is associated with the field Month, in the same format MM/YYYY.
First, create another variable to get to one year back:
LYDateLimit = date(addyears(date#(vDateLimit, 'MM/YYYY'),-1),'MM/YYYY')
So, if your enter vDateLimit = 01/2011, then your LYDateLimit will be 01/2010.  The set syntax is:
{<Month={'$(LYDateLimit)'}>}

Hope it will help you to figure out the rest if I missed anything.

Regards,
Michael

Not applicable
Author

Thanks... I'm almost there, so once I've created my variabl VDateLimit, i put the set analysis into the dimension....

{<Month={'$(VDateLimit)'}>}  and I tried replacing "Month" with my month field.  It didn't work.  My month field is MM/YYYY.

Not applicable
Author

Thanks... I'm almost there, so once I've created my variabl VDateLimit, i put the set analysis into the dimension....

{<Month={'$(VDateLimit)'}>}  and I tried replacing "Month" with my month field.  It didn't work.  My month field is MM/YYYY.

Anonymous
Not applicable
Author

Jim,

I can't tell what you miss.  See the attached simple example.  See what variables are there, and the expression in the bottom text box.

There could be nuances in your situation which I don't know about, so look at the attachment as an example rather than a solution.

Regards,

Michael

Not applicable
Author

Thanks Michael, this is great.  How does the last text object box know to subtract 12 months? and where is the LYDateLimit variable created?  Jim

Anonymous
Not applicable
Author

I created it in Variables Overview

nagaiank
Specialist III
Specialist III

If you change your dimension from

RollMonthDateAL

to

=Date(If(RollMonthDateAL > MonthStart(Today(),-12), RollMonthDateAL, Null()),'MM/YYYY')

You can limit the number of bars to 12

Anonymous
Not applicable
Author

Jim,

I usually don't download attachments, especialy of that size.

Judging by the response from Krishna, your requirement is not about the month one year prior to the "input box month", but 12 months prior.  If this is correct, Krishna's suggestion makes sense.  Except, the "Today()" in his expression should be replaced with the first date of the month which is in the input box.

Regards,

Michael

Not applicable
Author

Thanks Michael and Krishnamoorthy!!   This works and I will use both the "Today()" and the input box method.  Jim