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

Need help on calculated dimensions

Hi,

I need help on calculated dimension. I need to get max year in my calculated dimension and for that reason I have used the below expression:-

{Year=<=max(Year)>}Year

and also I need previous year as a calculated dimension:-

{Year=<=max(Year)-1>}Year

but it gives me an error.

please help me to solve this.

Thanks,

Sandip Ghosh

21 Replies
sujeetsingh
Master III
Master III

How can dimension get calculated for the complete set of values .

I think for this you need to first get the desired filter in your script.

ananyaghosh
Creator III
Creator III
Author

I have a year field and based on that I need to calculated Maximum year

marcus_sommer

I'm not sure if you it really needed as dimension. Often set analysis within the expressions is a better approach:

https://community.qlik.com/search.jspa?q=current+vs+previous

Simply create YTD, moving totals and comparisons versus Year Ago

- Marcus

tyagishaila
Specialist
Specialist

Hi Sandip,

You can try,

only(Year) & only(Year)-1

Let me know is it working or not.

stigchel
Partner - Master
Partner - Master

Like this:

Aggr(Only({<Year={'$(=Max(Year))','$(=Max(Year)-1)'}>} Year),Year)

tyagishaila
Specialist
Specialist

Calculated Dimension,

=aggr(if(Year=only(Year),Year,''),Year)

or

=aggr(if(Year=max(Year),Year,''),Year)

and along with click option Suppress When Value is Null

ananyaghosh
Creator III
Creator III
Author

I have three columns like this :-

Year  expense Income

2015 123         1234

2014 123         345

2013 123          345

2012  234        3345

Now I want to show Current year (Which is 2015) and previous year as a dimension and expression as sum(expense) and sum(income).

Now how to do that thing? means what I have to do in calculated dimensions.

please suggest.

Not applicable

We can achieve that using set analysis in a simple way.

Use:

sum({<Year = {2014,2015}>}expense) and sum({<Year = {2014,2015}>}income)


Thanks,

Singh

Anonymous
Not applicable

You don't have to use calculated dimension.  You can use separate expressions

sum({$<Year={"$(=year(today()))"}>} expense)

sum({$<Year={"$(=year(today())-1)"}>} expense)

Similar for income

But if you prefer calculated dimension, it is

aggr(only({<Year={"$(='<=' & year(today()) & '<=' (year(today())-1))"}>} Year), Year)