Forum Discussion

bourne2000's avatar
bourne2000
Icon for Helper V rankHelper V
5 years ago
Solved

Error in calculating Age column?

Hi

 

I am having Birthdate and calculated age in Power query using Durations. Most of the ages are correct. However, some of the year the age is coming wrong. Please see the snapshot.

 

 If you see the screenshot, the year 1951 appears multiple times, and the age calculated wrongly. This shows age 140, 210, some of the records it calculated correctly.

 

Could you please advise what went wrong?

  • bourne2000 

    I am not sure what calculation you used to get the age, anyhow, you can add the following code as a new custom column to calculate the correct age in years:

    =Number.RoundDown(
      Number.From( (Date.From(DateTime.LocalNow()) - [BirthDate] ) /365.25),
      0
    )

     

1 Reply

  • bourne2000 

    I am not sure what calculation you used to get the age, anyhow, you can add the following code as a new custom column to calculate the correct age in years:

    =Number.RoundDown(
      Number.From( (Date.From(DateTime.LocalNow()) - [BirthDate] ) /365.25),
      0
    )