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: 
Newbie777
Partner - Creator III
Partner - Creator III

Age function with decimal

Hi 

I am using Age function to calculate employee tenures, and I'd like to get two figures below decimal points, but only integer number is generated as the calculation result.  I'd like to see the months before the completion of 1 year to be also shown after joining the company.  Please could you let me know how I can get below decimal points for Age() function?  

Newbie7_0-1629645985445.png

Thanks a lot for your help.  

4 Replies
Newbie777
Partner - Creator III
Partner - Creator III
Author

As it seems Age() function is set at integer value, I decided to use a subtraction of hiring dates from Leaving date or max(DateField) to get the non-integer tenure figure.  The calculation result of the expression below is generated in number of days, and I'm wondering if there is a similar function to YearFrac in excel or Power BI in Qlik Sense to convert it to fraction of years.  

Newbie7_0-1629648309761.png

Thanks a lot for your help.

anthonyj
Creator III
Creator III

Hi,

If your function is returning the number days in tenure you could wrap it in a calculation like this:

num(((sum(Your calculation))/365),'#.##')

The hashes in the num( ) function will round your results to two decimal points.

I hope this helps.

Thanks

Anthony

Newbie777
Partner - Creator III
Partner - Creator III
Author

Hello,  

Thanks for your response, but I have a feeling that this formula with absolute value of 365 does not address the leap year issue which has 366 days (i.e. 29th February) every 4 years.  Is there a specific Qlik Sense formula which is addressing the intricacies of leap years to calculate year fractions?  

anthonyj
Creator III
Creator III

Hi,

I've been looking into the functionality of YearFrac( ) and I assume you're looking at the Basis "1" where it is calculating on Actual/Actual. I haven't been able to find any function in Qlik that calculates the same way as this. 

Regards

Anthony