Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Marisa
Contributor II
Contributor II

How to use a Set Analysis result as the n-value of AddYears function

I want to use the AddYears function in a dimension (column of a table), but not with a static n-value that indicate the years to add or subtract.

One of the Columns indicate the Depreciation Year. In order to indicate the depreciation years I had to do the following: AGGR(ONLY ({<[Attribute Code]={'DEPRECIATION YEARS'}>} [Attribute Value]),[Asset Code]))  this provides a number, e.g. 4

I now what to use that value in another column to indicate the Remaining Depreciation Year. I wanted to do the following: AddYears([Commissioned On Date] , AGGR(ONLY ({<[Attribute Code]={'DEPRECIATION YEARS'}>} [Attribute Value]),[Asset Code])) . This does however not work. 

When I do the following:  AddYears([Commissioned On Date] , 4) I get the answer I am looking for, but the n-value of the AddYears value will be dynamic for each Asset that is in the table.

Thanks is advance

Marisa

Labels (1)
1 Solution

Accepted Solutions
brunobertels
Master
Master

Hi 

What about creating a variable with you mesure to calculate the depreciate year 

And then use this variable in your addyear mesure 

variable : 

vDepreciate_Year = AGGR(ONLY ({<[Attribute Code]={'DEPRECIATION YEARS'}>} [Attribute Value]),[Asset Code]))

 

mesure : 

AddYears([Commissioned On Date] ,$(vDepreciate_Year ) )

 

Hope it helps 

View solution in original post

3 Replies
brunobertels
Master
Master

Hi 

What about creating a variable with you mesure to calculate the depreciate year 

And then use this variable in your addyear mesure 

variable : 

vDepreciate_Year = AGGR(ONLY ({<[Attribute Code]={'DEPRECIATION YEARS'}>} [Attribute Value]),[Asset Code]))

 

mesure : 

AddYears([Commissioned On Date] ,$(vDepreciate_Year ) )

 

Hope it helps 

Marisa
Contributor II
Contributor II
Author

Thanks for the reply.

I have tried that now, but I am still not getting an answer. 

Marisa
Contributor II
Contributor II
Author

Thank you so much. At first it did not work, but that was because the Depreciate_Year was seen as text and not a number. I just added num# in front of it and it work.

Thanks again

Marisa