# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
See why BI users voted Qlik #1 in 11 categories. GET REPORT
cancel
Showing results for
Did you mean:
Highlighted
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.

Marisa

Labels (1)

1 Solution

Accepted Solutions
Highlighted
Specialist II

Hi

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

variable :

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

mesure :

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

Hope it helps

3 Replies
Highlighted
Specialist II

Hi

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

variable :

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

mesure :

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

Hope it helps

Highlighted
Contributor II