How To Calculate Age In Power Bi

To calculate age in Power BI, you can use the DATEDIFF function along with the DATE function.

The DATEDIFF function calculates the difference between two dates, while the DATE function creates a date value from given year, month, and day values.

Here’s an example of how you can calculate age:

    
      DateDiff = DATEDIFF(
        'TableName'[BirthDate],
        DATE(YEAR(NOW()), MONTH(NOW()), DAY(NOW())),
        YEAR
      )
    
  

In this example, replace ‘TableName’ with the name of your table, and ‘BirthDate’ with the name of the column that contains the birth dates.

The DATEDIFF function takes three arguments:

  1. The start date: ‘TableName'[BirthDate]
  2. The end date: DATE(YEAR(NOW()), MONTH(NOW()), DAY(NOW())) – this gives you the current date
  3. The unit of measurement for the difference: YEAR – this will return the age in years

The result of the calculation will be a column that contains the ages corresponding to each birth date in your table.

Leave a comment