Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method that's a straightforward method that is a simple method of calculating the age. But, since DAX is the most popular language usedin several calculationsin Power BI, a lot of people are unaware of the option available within Power Query. In this blog , I'll detail how simple it is to calculateAge using Power BI using PowerBI. It is a methodis extremely useful for situations when it is necessary to perform the age calculation. Itcan be done in a previous row-by-row basis.

Calculate Age from a date

This is one of DimCustomer table , which is in the AdventureWorksDW table which functions as the column for birth dates. I've eliminated columns that aren't required to make it easier to read;

To calculate how old you are for each client, you'll need:

  • In Power BI Desktop, Click on Transform Data
  • In Power Query Editor window, ensure to select the first column, namely the Birthdate.
  • Select the Add Column Tab to add Columns. It is found under the "From Date & Time" section. Under Date, choose Age

That's about it. This calculates the calculate any variations to your Birthdate column, and the current date and date.

However, the age that is displayed when you look at the Age column doesn't appear like an age. It's due to the fact that it's a Duration.

Duration

Duration is a specific kind of data used to calculate the duration of a query in Power Query which represents the difference in the two DateTime values. Duration is a combination of four values:

days.hours.minutes.seconds

And that's exactly what you'll find in the above information. From a user's perspective they shouldn't be expected to read information in the same way as those mentioned above. There are methods to find each element of the time. Utilizing the Duration menu, there is a way that you can take the value of seconds, minutes, hours weeks and years from it.

For aid in calculating the age in years for instance it is easy to calculate Total Year:

Notice that the duration was measured in days , and then divided in 365 to calculate the year-long amount.

Rounding

Truthfully, nobody declares an age for their children as 53.813698630136983! They say 53, which is reduced to. It's simple to select the Rounding, then click round down using the Transform tab.

This will give you the years of experience:

It's then possible to purify other columns if like (or there's a chance that you've applied transforms through the Transform tab to avoid the need to create new columns) You can also name this column"Age".

Things to Know

  • Refresh The age calculated in this way will be changed when refreshing your database. Every refresh, the data will match the birthdate to the date and date that the refresh was made. This method is an earlier calculation of age. However, if you wish for the age calculation to be performed dynamically by using DAX This is what I've shown how you can make use of.
  • The reason for using Power Query: Benefits of calculating an age with Power Query is that the calculation is carried out after you refresh the report. The calculation is performed using an algorithm that makes the calculation simple, and there won't be any additional overhead when calculating the age using DAX for a measurement of of runtime.
  • Different scenarios. This isn't intended to be used to calculate the age of a person based on their birth date. This could be used to calculate stock age for products as well as the distinct dates and dates from one another.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He is a graduate of a BSc from Computer engineering. He have more that 20 years of experience in data analysis as well as the BI and databases fields, as well as programming and development mostly with Microsoft technologies. He has been an Microsoft Data Platform MVP for nine years in a row (from 2011 until the present) for his commitment to Microsoft BI. Reza is a frequent blogger, as well as the co-founder and editor of RADACAD. Reza is co-founder and organizer of Difinity the conference held located at New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He has written several books on MS SQL BI and also is writing other books. He was also a regular forum participant on online forums for technical matters, like MSDN and Experts-Exchange as well as moderator for the MSDN SQL Server forums, and is an MCP , the MCSE, as well as an MCITP in BI. He is the founder of the New Zealand Business Intelligence users group. In addition, he's the creator of the incredibly popular books Power BI from Rookie to Rock Star, which is available for free and has more than 170 pages of content. It also contains Power BI Pro Architecture, which is the Power BI Pro Architecture published by Apress.
He is an International speaker on Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday, and SQL users groups. And He is a Microsoft Certified Trainer.
Reza's ambition is to help you discover the right solutions for data. He's a Data enthusiast.This post was posted as Power BI, Power BI from Rookie to Rockstar, Power Query and included in Power BI, Power BI from Rookie to Rock Star, Power Query. The following is a great resource for you to bookmark.

Post navigation

Create Different Visual Pages by using Different Security Groups in Power the BIAge's Calculation of Years that is used to calculate Leap Year in Power BI by using Power Query

Comments

Popular posts from this blog

digital-converter

convert-to-bmp