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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Restricting a Dim Year value to max 2 values

Hello,

I am having year as Dimension and want to restrict it upto max two values....

Example: say, I am having 2013,2014,2015,2016....

on the base of selection of master calender it shud give me max two value, in common words like CY vs PY.

How I can do it at dimension level??

Regards,

Balraj Ahlawat

12 Replies
gautik92
Specialist III
Specialist III

you want to create a variable for previous year and in chart you have to use that variable in expression

then create a input box and call that variable in the inbut box

Anonymous
Not applicable
Author

I have defined a variable into Variable overview named VPY

now at dimension level I am using

If(year>=VPY, year)..

But its not working

jonathandienst
Partner - Champion III
Partner - Champion III

If you define the variable like this:

     =(Max(year) - 1)

(where the = sign is part of the variable defintion),

Then you can use it in the way you tried. If the defintion does not include the = sign, then you would need:

     If(year >= $(VPY). ....

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Jonathan,

I have already tried this but no success..

PFA..

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Dim : year

Expression: =sum({<year={'>=$(=Max(year) -1)<=$(=Max(year))'}>}sales)

Regards,

Jagan.

jagan
Partner - Champion III
Partner - Champion III

OR

No dimension:

Expression:

Current Year : Sum({<year={'$(=Max(year) -1)'}sales)

Previous Year : Sum({<year={'$(=Max(year))'}sales)


Hope this helps you.


Regards,

Jagan.

Kushal_Chawda

use calculated dimension as below

=aggr(Only({<year={">=$(=max(year)-1)"}>}year),year)

check suppress when values is NULL

see the attached

tresesco
MVP
MVP

PFA. You nneded a preceding '=' in the variable definition.

Anonymous
Not applicable
Author

Jagan,

At expression level I have tried same and it was working.

But I want to try at Dimension level not expression level.