1. Load your data:
Import your dataset into Power BI.
2. Open Power Query Editor:
Go to the "Home" tab and click on "Transform Data" to open the Power Query Editor.
3. Add Custom Columns:
In the Power Query Editor, select the column that contains your date of birth values.
4. Calculate Age:
Select the date of birth column.
Go to the "Add Column" tab.
Click on "Date" and then select "Age".
This will create a new column with the age calculated from the date of birth.
5. Convert Age to Years:
The age column created will be in duration format (days, hours, minutes, seconds).
To convert this to years, select the new age column.
Go to the "Transform" tab.
Click on "Duration" and then select "Total Years".
This will convert the duration to the total number of years.
6. Convert Age to Years In Whole Number:
In the above extracted column of "Total Years" go to column heading
You will find the type of dataset indicated as "1.2" i'e number
Left click on it, dropdown will appear
Select whole number from the dropdown
Your values will be rounded to nearest whole number
7. Close and Apply:
Once you have added the age column and converted it to years, click on "Close & Apply" to apply the changes and return to the main Power BI window.
You should now have a column with the age calculated from the date of birth in your dataset.