Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kolumam
Post Prodigy
Post Prodigy

Age in Years between two dates

I tried the below formulas to calculate the following:

Age as of 1st Jan 2020 = 

 

YEARFRAC(DATE(2020,3,1),DATE(2020,1,1),1)

 

which is 0.16393443

Age as of 1st Jan 2021 = 

 

YEARFRAC(DATE(2020,3,1),DATE(2021,1,1),1)

 

which is 0.83835616

When I add both 0.16393443+0.83835616 it is equal to 1.00229 something and is not 1.

What am I doing wrong? Please note I use YEARFRAC because I need the decimals and also I need to take into account of leap year.

----------------------------------------------------------------------------------------------------------------------

 

 

@parry2k @mahoney19  @parry2k @az38 @jdbuchanan71 @mahoneypat @edhans @harshnathani @v-kellya-msft @MFelix @Ashish_Mathur @BA_Pete @ryan_mayu @kbuckvol @Alexander76877 @Petazo @Mariusz @TomMartens @Greg_Deckler @tjd @Sean @mikstra @AllisonKennedy @EricHulshof @briandpeterson @USG_Phil @vpatel55 @mwegener @v-piga-msft @tex628 @sturlaws @Vvelarde @CheenuSing @MarcelBeug @Zubair_Muhammad @v-piga-msft @danextian @MattAL @MattAllington @roalexan @Alexander76877 @kgc 

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Kolumam ,

 

The YEARFRAC function will return a decimal number, which the internal data type is a signed IEEE 64-bit (8-byte) double-precision floating-point number. You may use ROUND function to limit the decimal places of data.

 

For reference: https://docs.microsoft.com/en-us/dax/yearfrac-function-dax.

 

Best Regards,

Amy 

AlB
Super User
Super User

 @Kolumam 

See if this helps:

https://www.sqlbi.com/blog/marco/2018/06/24/correct-calculate-of-age-in-dax-from-birthday/

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.