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

Product Portfolio Age Analysis

Can someone assist with the attached QV application.  I am calculating product portfolio age based on an "Action Date" and today' s date.  I have two ages, one is the PortfolioAge and the other PortfolioAgeLong.  The PortfolioAge is in numeric form so that i can be able to use the class function to build charts with product age class intervals.  The PortfolioAgeLong should give the true product age from the "ActionDate" in years, months and days.

The application seems not to be calculating the right ages as can be seen from the example below when reference is made to the ActionDate and today's date which means there is something wrong with the script:

Screen Shot 2016-03-18 at 09.51.50.png

  Please assist

Regards.

Chris

Message was edited by: Christopher Chitemerere Removed the calculation of fractional ages as this has been answered by Gysbert

1 Solution

Accepted Solutions
Gysbert_Wassenaar

See here:Re: Age in Year Month Day Format

age(Today(),MCAZActionDate) & ' Years and ' &(if(day(Today()) >= day(MCAZActionDate),

  mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12),

  if(mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)=0,11,mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)-1))) &' Months and ' &

  (if(day(Today()) >= day(MCAZActionDate),  day(Today()) - day(MCAZActionDate),  Today()-AddMonths(MCAZActionDate,12*age(Today(),MCAZActionDate)+mod(Year(Today())*12+Month(Today())-Year(MCAZActionDate)*12+Month(MCAZActionDate),12)-1))+1)  & ' days'


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

The Age function returns an integer value. If you want fractions the you'll have to use something like (Today()-MCAZActionDate)/365


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Many thanks Gysbert for an answer to the last part of my question.  The ages calculated in the application are wrong, can you assist on this through the attached application?

Gysbert_Wassenaar

See here:Re: Age in Year Month Day Format

age(Today(),MCAZActionDate) & ' Years and ' &(if(day(Today()) >= day(MCAZActionDate),

  mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12),

  if(mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)=0,11,mod((Year(Today())*12+Month(Today()))-(Year(MCAZActionDate)*12+Month(MCAZActionDate)),12)-1))) &' Months and ' &

  (if(day(Today()) >= day(MCAZActionDate),  day(Today()) - day(MCAZActionDate),  Today()-AddMonths(MCAZActionDate,12*age(Today(),MCAZActionDate)+mod(Year(Today())*12+Month(Today())-Year(MCAZActionDate)*12+Month(MCAZActionDate),12)-1))+1)  & ' days'


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thank you very much

Regards.